Files
ddns/src/config.rs
T

28 lines
534 B
Rust

use serde::Deserialize;
use std::{error::Error, fs};
#[derive(Deserialize)]
pub struct Config {
pub auth: Auth,
#[serde(rename = "entry")]
pub entries: Vec<Entry>,
}
#[derive(Deserialize)]
pub struct Auth {
pub key: String,
pub secret_key: String,
}
#[derive(Deserialize)]
pub struct Entry {
pub domain: String,
pub subdomains: Vec<String>,
}
pub fn load(path: &str) -> Result<Config, Box<dyn Error>> {
let raw = fs::read_to_string(&path)?;
let config = toml::from_str(&raw)?;
Ok(config)
}