From 2b9e1eccb557901714c33cb498ddadc25694ca29 Mon Sep 17 00:00:00 2001 From: donpat1to Date: Sat, 9 Aug 2025 12:47:50 +0200 Subject: [PATCH] fixed returns --- WatcherAgent/src/hardware/cpu.rs | 6 +++--- WatcherAgent/src/hardware/disk.rs | 2 +- WatcherAgent/src/hardware/memory.rs | 6 ++++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/WatcherAgent/src/hardware/cpu.rs b/WatcherAgent/src/hardware/cpu.rs index 46c445f..f876292 100644 --- a/WatcherAgent/src/hardware/cpu.rs +++ b/WatcherAgent/src/hardware/cpu.rs @@ -53,7 +53,7 @@ pub async fn get_cpu_temp() -> Result> { .and_then(|s| s.split_whitespace().next()) { if let Ok(temp) = temp_str.replace("°C", "").parse::() { - return Ok(temp); + return Ok(temp.into()); } } } @@ -63,7 +63,7 @@ pub async fn get_cpu_temp() -> Result> { // 2. Sysfs (Intel/AMD) if let Ok(content) = fs::read_to_string("/sys/class/thermal/thermal_zone0/temp") { if let Ok(temp) = content.trim().parse::() { - return Ok(temp / 1000.0); + return Ok((temp / 1000.0).into()); } } @@ -78,7 +78,7 @@ pub async fn get_cpu_temp() -> Result> { for path in paths.flatten() { if let Ok(content) = fs::read_to_string(&path) { if let Ok(temp) = content.trim().parse::() { - return Ok(temp / 1000.0); + return Ok((temp / 1000.0).into()); } } } diff --git a/WatcherAgent/src/hardware/disk.rs b/WatcherAgent/src/hardware/disk.rs index 0bf60ef..fa67966 100644 --- a/WatcherAgent/src/hardware/disk.rs +++ b/WatcherAgent/src/hardware/disk.rs @@ -13,7 +13,7 @@ pub struct DiskInfo { pub async fn get_disk_info() -> Result { let disks = Disks::new_with_refreshed_list(); - let disk_types = [ + let _disk_types = [ sysinfo::DiskKind::HDD, sysinfo::DiskKind::SSD, sysinfo::DiskKind::Unknown(0), diff --git a/WatcherAgent/src/hardware/memory.rs b/WatcherAgent/src/hardware/memory.rs index 6a5222e..35a71cb 100644 --- a/WatcherAgent/src/hardware/memory.rs +++ b/WatcherAgent/src/hardware/memory.rs @@ -1,3 +1,5 @@ +use std::error::Error; + use anyhow::Result; use sysinfo::System; @@ -19,7 +21,7 @@ pub async fn get_memory_info() -> Result { }) } -pub fn _get_memory_usage(sys: &mut System) -> f64 { +pub fn _get_memory_usage(sys: &mut System) -> Result> { sys.refresh_memory(); - (sys.used_memory() as f64 / sys.total_memory() as f64) * 100.0 + Ok((sys.used_memory() as f64 / sys.total_memory() as f64) * 100.0) }