fixed returns

This commit is contained in:
2025-08-09 12:43:21 +02:00
parent 93a40fe584
commit 2e4d17f964
2 changed files with 56 additions and 14 deletions

View File

@@ -53,7 +53,7 @@ pub async fn get_cpu_temp() -> Result<f64, Box<dyn Error>> {
.and_then(|s| s.split_whitespace().next())
{
if let Ok(temp) = temp_str.replace("°C", "").parse::<f32>() {
return Some(temp);
return Ok(temp);
}
}
}
@@ -63,7 +63,7 @@ pub async fn get_cpu_temp() -> Result<f64, Box<dyn Error>> {
// 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::<f32>() {
return Some(temp / 1000.0);
return Ok(temp / 1000.0);
}
}
@@ -78,16 +78,14 @@ pub async fn get_cpu_temp() -> Result<f64, Box<dyn Error>> {
for path in paths.flatten() {
if let Ok(content) = fs::read_to_string(&path) {
if let Ok(temp) = content.trim().parse::<f32>() {
return Some(temp / 1000.0);
return Ok(temp / 1000.0);
}
}
}
}
}
Err(anyhow::anyhow!(
"Could not find CPU temperature using sensors or sysfs"
))
Err(anyhow::anyhow!("Could not find CPU temperature using sensors or sysfs").into())
}
#[cfg(target_os = "windows")]