use serde::{Deserialize, Serialize};
use std::path::PathBuf;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct OptimizerConfig {
pub pressure_threshold: u32,
pub critical_threshold: u32,
pub min_interval_secs: u64,
pub neural_enabled: bool,
pub model_path: PathBuf,
pub protected_processes: Vec<String>,
pub startup_mode: bool,
pub aggressive_mode: bool,
pub learning_enabled: bool,
pub ewc_lambda: f32,
pub benchmark_mode: bool,
}
impl Default for OptimizerConfig {
fn default() -> Self {
Self {
pressure_threshold: 80,
critical_threshold: 95,
min_interval_secs: 30,
neural_enabled: true,
model_path: PathBuf::from("./data/neural"),
protected_processes: vec![
"System".into(),
"csrss.exe".into(),
"smss.exe".into(),
"lsass.exe".into(),
"services.exe".into(),
],
startup_mode: false,
aggressive_mode: false,
learning_enabled: true,
ewc_lambda: 0.4,
benchmark_mode: false,
}
}
}
impl OptimizerConfig {
pub fn load(path: &std::path::Path) -> Result<Self, Box<dyn std::error::Error>> {
let content = std::fs::read_to_string(path)?;
let config: Self = toml::from_str(&content)?;
Ok(config)
}
pub fn save(&self, path: &std::path::Path) -> Result<(), Box<dyn std::error::Error>> {
let content = toml::to_string_pretty(self)?;
std::fs::write(path, content)?;
Ok(())
}
}