diff --git a/src/cpu.rs b/src/cpu.rs index 10a7acb..69ef10a 100644 --- a/src/cpu.rs +++ b/src/cpu.rs @@ -432,8 +432,8 @@ pub fn set_battery_charge_thresholds(start_threshold: u8, stop_threshold: u8) -> // Try each threshold path pattern for this battery for pattern in &threshold_paths { - let start_threshold_path = ps_path.join(&pattern.start_path); - let stop_threshold_path = ps_path.join(&pattern.stop_path); + let start_threshold_path = ps_path.join(pattern.start_path); + let stop_threshold_path = ps_path.join(pattern.stop_path); if start_threshold_path.exists() && stop_threshold_path.exists() { // Found a battery with threshold support @@ -460,8 +460,8 @@ pub fn set_battery_charge_thresholds(start_threshold: u8, stop_threshold: u8) -> let mut success_count = 0; for battery in supported_batteries { - let start_path = battery.path.join(&battery.pattern.start_path); - let stop_path = battery.path.join(&battery.pattern.stop_path); + let start_path = battery.path.join(battery.pattern.start_path); + let stop_path = battery.path.join(battery.pattern.stop_path); // Attempt to set both thresholds match ( diff --git a/src/monitor.rs b/src/monitor.rs index 259e872..811f3e9 100644 --- a/src/monitor.rs +++ b/src/monitor.rs @@ -48,7 +48,7 @@ pub fn get_system_info() -> SystemInfo { } #[derive(Debug, Clone, Copy)] -struct CpuTimes { +pub struct CpuTimes { user: u64, nice: u64, system: u64, @@ -57,8 +57,6 @@ struct CpuTimes { irq: u64, softirq: u64, steal: u64, - guest: u64, - guest_nice: u64, } impl CpuTimes { @@ -147,18 +145,6 @@ fn read_all_cpu_times() -> Result> { parts[8] )) })?, - guest: parts[9].parse().map_err(|_| { - SysMonitorError::ProcStatParseError(format!( - "Failed to parse guest time: {}", - parts[9] - )) - })?, - guest_nice: parts[10].parse().map_err(|_| { - SysMonitorError::ProcStatParseError(format!( - "Failed to parse guest_nice time: {}", - parts[10] - )) - })?, }; cpu_times_map.insert(core_id, times); } @@ -288,7 +274,7 @@ pub fn get_cpu_core_info( None } else { let usage = 100.0 * (1.0 - (idle_diff as f32 / total_diff as f32)); - Some(usage.max(0.0).min(100.0)) // clamp between 0 and 100 + Some(usage.clamp(0.0, 100.0)) // clamp between 0 and 100 } };