Initial commit

- rough filestructure
- first simplistic daemon
This commit is contained in:
malte
2025-11-06 11:38:20 +01:00
parent af8df2e62e
commit d843c08425
10 changed files with 1389 additions and 0 deletions
+42
View File
@@ -0,0 +1,42 @@
//
// Parsing the config file
//
use std::fs;
use serde_derive::Deserialize;
#[derive(Deserialize, Debug)]
pub struct HuskConfig {
logfile_config: Option<String>,
}
impl HuskConfig {
pub fn load(path: &String) -> Option<Self> {
match fs::read_to_string(path) {
Ok(data) => {
match toml::from_str(data.as_str()) {
Ok(configuration) => Some(configuration),
Err(e) => {
eprintln!("Error while parsing config file: {:?}", e);
None
}
}
},
Err(e) => {
eprintln!("Error while reading config file: {:?}", e);
None
}
}
}
pub fn logfile_config(&self) -> String {
match &self.logfile_config {
Some(c) => c.clone(),
None => {
eprintln!("Using logging configuration from 'log4rs.yml'");
"log4rs.yml".to_string()
},
}
}
}