1 use std
::{fs
::File
, time
};
6 ser
::{to_writer_pretty
, PrettyConfig
},
8 use serde
::{Deserialize
, Serialize
};
10 #[derive(Debug, Clone, Deserialize, Serialize)]
12 pub pub_keys
: Vec
<String
>,
13 pub smtp_login
: String
,
14 pub smtp_password
: String
,
18 pub fn default() -> Self {
21 smtp_login
: "login".to_string(),
22 smtp_password
: "password".to_string(),
26 pub fn read(file_path
: &str) -> Result
<Config
> {
27 match File
::open(file_path
) {
28 Ok(file
) => from_reader(file
).map_err(|e
| e
.into()),
29 // The file doesn't exit -> create it with default values.
31 let file
= File
::create(file_path
)?
;
32 let default_config
= Config
::default();
33 to_writer_pretty(file
, &default_config
, PrettyConfig
::new())?
;