diff options
| author | Serguey Parkhomovsky <xindigo@gmail.com> | 2026-03-03 20:51:07 -0800 |
|---|---|---|
| committer | Serguey Parkhomovsky <xindigo@gmail.com> | 2026-03-03 20:51:07 -0800 |
| commit | b0e11d29dfc5f2cf9678872e782be2ed0625ef30 (patch) | |
| tree | 74d8c0fa198e08023933f8c049849639788687e7 /src | |
| parent | 7c3f6431c0f162eadffda456366c1071eaf9dfe8 (diff) | |
get it to build
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib.rs | 6 | ||||
| -rw-r--r-- | src/main.rs | 4 |
2 files changed, 8 insertions, 2 deletions
@@ -12,6 +12,12 @@ pub struct Config { pub printers: Vec<Printer>, } +impl Config { + pub fn load(toml: &str) -> Config { + toml::from_str(toml).expect("Couldn't parse config.toml") + } +} + #[derive(Debug, Deserialize)] #[serde(tag = "type", rename_all = "lowercase")] pub enum Printer { diff --git a/src/main.rs b/src/main.rs index 7660108..4fbd24a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,10 +9,10 @@ use tokio::sync::Mutex; #[tokio::main] async fn main() { let content = fs::read_to_string("config.toml").expect("Couldn't read config.toml"); - let config: Config = toml::from_str(&content).expect("Couldn't parse config.toml"); + let config = Config::load(&content); let state = Arc::new(Mutex::new(HashMap::<String, PrinterState>::new())); - for printer in &config.printers { + for printer in config.printers { match printer { Printer::Prusa { name, host, .. } => { println!("Found Prusa: {} at {}", name, host); |
