Load config file on startup

This commit is contained in:
Joscha 2022-08-25 22:12:29 +02:00
parent 8419afd2e1
commit d61e0ceab7
5 changed files with 49 additions and 12 deletions

16
src/config.rs Normal file
View file

@ -0,0 +1,16 @@
use std::fs;
use std::path::Path;
use serde::Deserialize;
use crate::macros::ok_or_return;
#[derive(Debug, Default, Deserialize)]
pub struct Config {}
impl Config {
pub fn load(path: &Path) -> Self {
let content = ok_or_return!(fs::read_to_string(path), Self::default());
ok_or_return!(toml::from_str(&content), Self::default())
}
}