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
>,
16 pub fn default() -> Self {
17 Config
{ pub_keys
: vec
![] }
20 pub fn read(file_path
: &str) -> Result
<Config
> {
21 match File
::open(file_path
) {
22 Ok(file
) => from_reader(file
).map_err(|e
| e
.into()),
23 // The file doesn't exit -> create it with default values.
25 let file
= File
::create(file_path
)?
;
26 let default_config
= Config
::default();
27 to_writer_pretty(file
, &default_config
, PrettyConfig
::new())?
;