sysfs_class/hwmon/
fan.rs

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