ruvector_memopt/core/
config.rs1use serde::{Deserialize, Serialize};
4use std::path::PathBuf;
5
6#[derive(Debug, Clone, Serialize, Deserialize)]
8pub struct OptimizerConfig {
9 pub pressure_threshold: u32,
11
12 pub critical_threshold: u32,
14
15 pub min_interval_secs: u64,
17
18 pub neural_enabled: bool,
20
21 pub model_path: PathBuf,
23
24 pub protected_processes: Vec<String>,
26
27 pub startup_mode: bool,
29
30 pub aggressive_mode: bool,
32
33 pub learning_enabled: bool,
35
36 pub ewc_lambda: f32,
38
39 pub benchmark_mode: bool,
41}
42
43impl Default for OptimizerConfig {
44 fn default() -> Self {
45 Self {
46 pressure_threshold: 80,
47 critical_threshold: 95,
48 min_interval_secs: 30,
49 neural_enabled: true,
50 model_path: PathBuf::from("./data/neural"),
51 protected_processes: vec![
52 "System".into(),
53 "csrss.exe".into(),
54 "smss.exe".into(),
55 "lsass.exe".into(),
56 "services.exe".into(),
57 ],
58 startup_mode: false,
59 aggressive_mode: false,
60 learning_enabled: true,
61 ewc_lambda: 0.4,
62 benchmark_mode: false,
63 }
64 }
65}
66
67impl OptimizerConfig {
68 pub fn load(path: &std::path::Path) -> Result<Self, Box<dyn std::error::Error>> {
70 let content = std::fs::read_to_string(path)?;
71 let config: Self = toml::from_str(&content)?;
72 Ok(config)
73 }
74
75 pub fn save(&self, path: &std::path::Path) -> Result<(), Box<dyn std::error::Error>> {
77 let content = toml::to_string_pretty(self)?;
78 std::fs::write(path, content)?;
79 Ok(())
80 }
81}