From ae7ef10b67737f08a86743f687bca30a12e9e17a Mon Sep 17 00:00:00 2001 From: salmonik Date: Sun, 12 Jul 2026 19:38:03 +0200 Subject: first stable --- src/config.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/config.rs (limited to 'src/config.rs') diff --git a/src/config.rs b/src/config.rs new file mode 100644 index 0000000..d9f6103 --- /dev/null +++ b/src/config.rs @@ -0,0 +1,23 @@ +use serde::Deserialize; +use std::path::PathBuf; + +#[derive(Debug, Clone, Deserialize)] +pub struct Config { + pub server_directory: PathBuf, + pub webui_port: u16, + pub max_memory_mb: u32, + pub initial_superuser: String, + pub initial_superuser_password: String, +} + +impl Config { + pub fn load() -> Result { + let content = std::fs::read_to_string("config.toml") + .map_err(|e| format!("Failed to read config.toml: {e}"))?; + + let config: Config = + toml::from_str(&content).map_err(|e| format!("Failed to parse config.toml: {e}"))?; + + Ok(config) + } +} -- cgit v1.2.3