lj_templates_rust/src/conf.rs

25 lines
482 B
Rust

use std::error::Error;
use config::Config;
use serde::{Serialize, Deserialize};
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Conf {
pub debug: bool,
pub laser_id: u8,
pub client_id: u8,
pub redis_url: String,
pub framerate: u8,
}
impl Conf {
pub fn new(path: &str) -> Result<Conf, Box<dyn Error>> {
let settings = Config::builder()
.add_source(config::File::with_name(path))
.build()?;
let conf: Conf = settings.try_deserialize()?;
Ok(conf)
}
}