Private
Public Access
1
0
Files
linux_patch_api/src/config/loader.rs
Echo afcd172ee5 Phase 0: Rust project scaffolding (M0 complete)
Completed Rust project initialization:
- Cargo.toml with all dependencies (actix-web, tokio, rustls, etc.)
- Project structure (src/, tests/, configs/)
- Module declarations (api, auth, config, jobs, logging, packages, systemd)
- Clippy and rustfmt configured
- Initial lib.rs and main.rs with logging setup
- Config examples (config.yaml.example, whitelist.yaml.example)

Dependencies resolved and project compiles successfully.
Rust toolchain 1.94.1 installed.
2026-04-09 18:15:35 +00:00

48 lines
1.1 KiB
Rust

//! Configuration Loader - YAML config loading
//!
//! Loads and parses YAML configuration files.
use anyhow::{Context, Result};
use serde::Deserialize;
/// Server configuration
#[derive(Debug, Deserialize, Clone)]
pub struct ServerConfig {
pub port: u16,
pub bind: String,
}
/// Jobs configuration
#[derive(Debug, Deserialize, Clone)]
pub struct JobsConfig {
pub max_concurrent: usize,
pub timeout_minutes: u64,
}
/// Logging configuration
#[derive(Debug, Deserialize, Clone)]
pub struct LoggingConfig {
pub level: String,
}
/// Application configuration
#[derive(Debug, Deserialize, Clone)]
pub struct AppConfig {
pub server: ServerConfig,
pub jobs: JobsConfig,
pub logging: LoggingConfig,
}
impl AppConfig {
/// Load configuration from a YAML file
pub fn load(path: &str) -> Result<Self> {
let content = std::fs::read_to_string(path)
.with_context(|| format!("Failed to read config file: {}", path))?;
let config: AppConfig = serde_yaml::from_str(&content)
.with_context(|| format!("Failed to parse config file: {}", path))?;
Ok(config)
}
}