1 use std
::{fs
::File
, time
};
3 use ron
::{de
::from_reader
, ser
::to_writer
};
4 use serde
::{Deserialize
, Serialize
};
6 use crate::error
::Result
;
8 #[derive(Debug, Clone, Deserialize, Serialize)]
10 pub delay_between_check
: time
::Duration
,
12 pub domains
: Vec
<(String
, String
)>, // Hostname, domain.
17 pub fn default() -> Self {
19 delay_between_check
: time
::Duration
::from_secs(120),
20 api_key
: String
::from(""),
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(file
, &default_config
)?
;