summaryrefslogtreecommitdiffstats
path: root/src/config.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/config.rs23
1 files changed, 23 insertions, 0 deletions
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 @@
1use serde::Deserialize;
2use std::path::PathBuf;
3
4#[derive(Debug, Clone, Deserialize)]
5pub struct Config {
6 pub server_directory: PathBuf,
7 pub webui_port: u16,
8 pub max_memory_mb: u32,
9 pub initial_superuser: String,
10 pub initial_superuser_password: String,
11}
12
13impl Config {
14 pub fn load() -> Result<Self, String> {
15 let content = std::fs::read_to_string("config.toml")
16 .map_err(|e| format!("Failed to read config.toml: {e}"))?;
17
18 let config: Config =
19 toml::from_str(&content).map_err(|e| format!("Failed to parse config.toml: {e}"))?;
20
21 Ok(config)
22 }
23}