pub mod browser;
pub mod electron;
pub mod docker;
pub mod leaks;
pub mod suggestions;
pub use browser::BrowserOptimizer;
pub use electron::ElectronManager;
pub use docker::DockerManager;
pub use leaks::LeakDetector;
pub use suggestions::SmartSuggestions;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum AppCategory {
Browser,
Electron,
Development,
Creative,
Communication,
Media,
System,
Container,
AI,
Other,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AppProcess {
pub pid: u32,
pub name: String,
pub category: AppCategory,
pub memory_mb: f64,
pub cpu_percent: f32,
pub parent_app: Option<String>,
pub is_main_process: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AppInfo {
pub name: String,
pub category: AppCategory,
pub process_count: usize,
pub total_memory_mb: f64,
pub total_cpu_percent: f32,
pub main_pid: Option<u32>,
pub pids: Vec<u32>,
pub is_idle: bool,
pub idle_duration_secs: u64,
}
impl AppInfo {
pub fn is_memory_hog(&self) -> bool {
self.total_memory_mb > 500.0
}
pub fn is_cpu_intensive(&self) -> bool {
self.total_cpu_percent > 10.0
}
pub fn optimization_priority(&self) -> f64 {
let mut priority = 0.0;
priority += self.total_memory_mb / 100.0;
priority += self.total_cpu_percent as f64 * 0.5;
if self.is_idle {
priority *= 1.5;
}
priority += self.process_count as f64 * 2.0;
priority
}
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum OptimizationAction {
Close,
Suspend,
TrimMemory,
Restart,
ReduceTabs { suggested_count: usize },
SuspendTabs,
StopContainer,
PauseContainer,
ClearCache,
None,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct OptimizationResult {
pub app_name: String,
pub action: OptimizationAction,
pub success: bool,
pub memory_freed_mb: f64,
pub message: String,
}