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 Ok(temp);
|
||||
return Ok(temp.into());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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 Ok(temp / 1000.0);
|
||||
return Ok((temp / 1000.0).into());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ 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 Ok(temp / 1000.0);
|
||||
return Ok((temp / 1000.0).into());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -13,7 +13,7 @@ pub struct DiskInfo {
|
||||
|
||||
pub async fn get_disk_info() -> Result<DiskInfo> {
|
||||
let disks = Disks::new_with_refreshed_list();
|
||||
let disk_types = [
|
||||
let _disk_types = [
|
||||
sysinfo::DiskKind::HDD,
|
||||
sysinfo::DiskKind::SSD,
|
||||
sysinfo::DiskKind::Unknown(0),
|
||||
|
@@ -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<MemoryInfo> {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn _get_memory_usage(sys: &mut System) -> f64 {
|
||||
pub fn _get_memory_usage(sys: &mut System) -> Result<f64, Box<dyn Error>> {
|
||||
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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user