Initial commit for rewrite

This commit is contained in:
2025-04-05 00:50:12 +03:00
commit 5b686e38c4
9 changed files with 1053 additions and 0 deletions

21
src/temperature.rs Normal file
View File

@@ -0,0 +1,21 @@
use std::fs;
use std::io;
pub struct TemperatureMonitor {
temp_path: String,
}
impl TemperatureMonitor {
pub fn new(temp_path: String) -> Self {
TemperatureMonitor { temp_path }
}
pub fn read_celsius(&self) -> Result<f32, io::Error> {
let temp_str = fs::read_to_string(&self.temp_path)?;
let temp_millicelsius = temp_str.trim().parse::<u32>()
.map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))?;
// Convert millidegrees to degrees
Ok(temp_millicelsius as f32 / 1000.0)
}
}