blob: d9f61031493901b9a31f7ae75c8a9646f031dbdb (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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<Self, String> {
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)
}
}
|