23 lines
537 B
Rust
23 lines
537 B
Rust
|
use config::Config;
|
||
|
use serde::{Deserialize, Serialize};
|
||
|
use std::error::Error;
|
||
|
|
||
|
#[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)
|
||
|
}
|
||
|
}
|