rnetmon/src/outputs/mod.rs

21 lines
585 B
Rust

pub mod espeak;
pub mod light_beewi_bbl227;
pub mod stdout;
use crate::output::*;
use std::collections::HashMap;
pub fn factory(
name: &str,
config: &HashMap<String, serde_yaml::Value>,
) -> Result<Box<Output>, Box<dyn std::error::Error>> {
match name {
"stdout" => Ok(Box::new(stdout::Stdout::new(&config)?)),
"espeak" => Ok(Box::new(espeak::Espeak::new(&config)?)),
"light_beewi_bbl227" => Ok(Box::new(light_beewi_bbl227::BluetoothLightbulb::new(
&config,
)?)),
_ => panic!("Unknown monitor name: {}", name),
}
}