diff options
| author | salmonik <salmonik@tuta.io> | 2026-07-12 19:38:03 +0200 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-07-12 19:38:03 +0200 |
| commit | ae7ef10b67737f08a86743f687bca30a12e9e17a (patch) | |
| tree | 056539ab76b801559dc8d07ee6599220e2bd8e07 /src/config.rs | |
| parent | architecture (diff) | |
| download | minecraft-ui-ae7ef10b67737f08a86743f687bca30a12e9e17a.tar.gz minecraft-ui-ae7ef10b67737f08a86743f687bca30a12e9e17a.zip | |
first stable
Diffstat (limited to 'src/config.rs')
| -rw-r--r-- | src/config.rs | 23 |
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 @@ | |||
| 1 | use serde::Deserialize; | ||
| 2 | use std::path::PathBuf; | ||
| 3 | |||
| 4 | #[derive(Debug, Clone, Deserialize)] | ||
| 5 | pub 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 | |||
| 13 | impl 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 | } | ||
