Load config file on startup
This commit is contained in:
parent
8419afd2e1
commit
d61e0ceab7
5 changed files with 49 additions and 12 deletions
16
src/config.rs
Normal file
16
src/config.rs
Normal 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())
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue