use serde::Deserialize;
use config::{Config, ConfigError, File};
#[derive(Debug, Deserialize, Clone)]
pub struct UiSettings {
pub theme: String,
pub page_size: usize,
pub auto_refresh: bool,
}
#[derive(Debug, Deserialize, Clone)]
pub struct AnalysisSettings {
pub default_sample_size: usize,
pub enable_anomaly_detection: bool,
pub correlation_threshold: f64,
}
#[derive(Debug, Deserialize, Clone)]
pub struct VisualizationSettings {
pub max_chart_width: u16,
pub max_chart_height: u16,
pub use_unicode: bool,
}
#[derive(Debug, Deserialize, Clone)]
pub struct Settings {
pub ui: UiSettings,
pub analysis: AnalysisSettings,
pub visualization: VisualizationSettings,
}
impl Settings {
pub fn new() -> Result<Self, ConfigError> {
let builder = Config::builder()
.add_source(File::with_name("config/default.toml"));
builder.build()?.try_deserialize()
}
}