aboutsummaryrefslogtreecommitdiff
path: root/src/config.rs
blob: 29145b8166271f2a68c28333b337b301a0f27f88 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
use serde::Deserialize;
use std::path::PathBuf;

#[derive(Deserialize, Debug)]
pub struct Config {
    pub to: String,
    pub from: String,
    pub account_sid: String,
    pub auth_token: String,
    pub reboot: RebootConfig,
    pub hello: HelloConfig,
}

#[derive(Deserialize, Debug)]
pub struct RebootConfig {
    pub ifname: String,
}

#[derive(Deserialize, Debug)]
pub struct HelloConfig {}

impl Config {
    pub fn load_from_file(filename: &PathBuf) -> std::io::Result<Config> {
        let content = std::fs::read_to_string(filename)?;
        Ok(toml::from_str(&content)?)
    }
}