5 ser
::{to_writer_pretty
, PrettyConfig
},
7 use serde
::{Deserialize
, Serialize
};
11 #[derive(Debug, Deserialize, Serialize)]
12 pub enum MachineName
{
17 #[derive(Debug, Deserialize, Serialize)]
19 pub machine_name
: MachineName
,
22 // Average temperature between CPU and GPU.
23 pub cold_temperature
: f32,
24 pub hot_temperature
: f32,
27 type Result
<T
> = std
::result
::Result
<T
, Box
<dyn std
::error
::Error
>>;
30 fn default() -> Self {
32 machine_name
: MachineName
::Jiji
,
43 cold_temperature
: 55.,
48 pub fn read(file_path
: &str) -> Result
<Settings
> {
49 match File
::open(file_path
) {
50 Ok(file
) => from_reader(file
).map_err(|e
| e
.into()),
52 let file
= File
::create(file_path
)?
;
53 let default_config
= Settings
::default();
54 to_writer_pretty(file
, &default_config
, PrettyConfig
::new())?
;