1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
use std::io::Result; use {HwMon, SysClass}; pub struct HwMonTemp<'a> { hwmon: &'a HwMon, id: u64, } impl<'a> HwMonTemp<'a> { pub fn new(hwmon: &'a HwMon, id: u64) -> Result<Self> { let s = Self { hwmon, id }; s.input()?; Ok(s) } pub fn label(&self) -> Result<String> { self.hwmon.trim_file(&format!("temp{}_label", self.id)) } pub fn input(&self) -> Result<u32> { self.hwmon.parse_file(&format!("temp{}_input", self.id)) } pub fn lcrit(&self) -> Result<u32> { self.hwmon.parse_file(&format!("temp{}_lcrit", self.id)) } pub fn min(&self) -> Result<u32> { self.hwmon.parse_file(&format!("temp{}_min", self.id)) } pub fn max(&self) -> Result<u32> { self.hwmon.parse_file(&format!("temp{}_max", self.id)) } pub fn crit(&self) -> Result<u32> { self.hwmon.parse_file(&format!("temp{}_crit", self.id)) } pub fn emergency(&self) -> Result<u32> { self.hwmon.parse_file(&format!("temp{}_emergency", self.id)) } }