about summary refs log tree commit diff
path: root/tools/sendsms/src/config.rs
blob: da9435a31628aa7deb33f16d05aa3afbda76edbf (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
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,
}

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

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)?)
    }
}