fixed returns
This commit is contained in:
@@ -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")]
|
||||
|
Reference in New Issue
Block a user