use serde::Deserialize; use std::fs; #[derive(Deserialize, Clone, Default)] pub struct Config { pub scheme: Option, pub port: Option, pub mail: Option, pub lang: Option, } pub fn get_config(file_path: &str) -> Config { match fs::read_to_string(file_path) { Ok(file) => match toml::from_str(&file) { Ok(stored_config) => stored_config, Err(file_error) => { panic!("Error in config file: {file_error}"); } }, Err(_) => // No config file { Config { scheme: Some("http".to_string()), port: Some(8080), ..Config::default() } } } }