Skip to content

Commit

Permalink
add config utility
Browse files Browse the repository at this point in the history
  • Loading branch information
ns-mkusper committed Aug 26, 2024
1 parent dec50a5 commit 67fd4ec
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//! Utility config
use crate::streaming_devices::streaming_device::StreamingDevice;
use anyhow::Error;
use serde::Deserialize;
use std::fs;
use std::path::Path;
use toml::from_str;

#[derive(Deserialize, Debug)]
pub struct Config {
// TODO: implement complete config file
streaming_devices: Vec<StreamingDevice>,
}

pub fn parse_config_from_toml<P: AsRef<Path>>(path: P) -> Result<Config, Error> {
let toml_content = fs::read_to_string(path).unwrap();
let config: Config = from_str(&toml_content)?;
Ok(config)
}

0 comments on commit 67fd4ec

Please sign in to comment.