1 use std
::{fmt
, fs
::File
};
3 use ron
::de
::from_reader
;
4 use serde
::Deserialize
;
8 #[derive(Deserialize, Clone)]
11 pub smtp_login
: String
,
12 pub smtp_password
: String
,
15 // Avoid to print passwords.
16 impl fmt
::Debug
for Config
{
17 fn fmt(&self, f
: &mut fmt
::Formatter
<'_
>) -> fmt
::Result
{
18 f
.debug_struct("Config")
19 .field("port", &self.port
)
20 .field("smtp_login", &self.smtp_login
)
21 .field("smtp_password", &"*****")
26 pub fn load() -> Config
{
27 let f
= File
::open(consts
::FILE_CONF
)
28 .unwrap_or_else(|_
| panic!("Failed to open configuration file {}", consts
::FILE_CONF
));
29 match from_reader(f
) {
31 Err(e
) => panic!("Failed to load config: {}", e
),