[−][src]Crate libmedium
A library that lets you use lm_sensor's sysfs interface from rust.
Similar to libsensors this library lets you use the various sensors in your system.
#Examples
Print the temperature of all the temp sensors in your system:
use rsl::parse_hwmons_read_only; use rsl::sensors::{Sensor, SensorBase}; fn main() { let hwmons = parse_hwmons_read_only().unwrap(); for (hwmon_index, hwmon_name, hwmon) in &hwmons { println!("hwmon{} with name {}:", hwmon_index, hwmon_name); for (_, temp_sensor) in hwmon.temps() { let temperature = temp_sensor.read_input().unwrap(); println!("\t{}: {}", temp_sensor.name(), temperature); } } }
Set the pwm value of all your pwm capable fans to full speed:
use rsl::parse_hwmons_read_write; use rsl::sensors::pwm::{Pwm, PwmEnable, PwmSensor}; fn main() { let hwmons = parse_hwmons_read_write().unwrap(); for (_, _, hwmon) in &hwmons { for (_, pwm) in hwmon.pwms() { pwm.write_enable(PwmEnable::ManualControl).unwrap(); pwm.write_pwm(Pwm::from_percent(100.0)).unwrap(); } } }
Modules
hwmon | Module containing the Hwmon struct and related functionality. |
sensors | Module containing the sensors and their functionality. |
Structs
Hwmons | This crate's central struct. It stores all parsed hwmons which you can query either by name or by index. You should not create this struct yourself but use the parse_hwmons* functions. |
Iter | An iterator over all parsed hwmons. |
Enums
ParsingError |
Functions
parse_hwmons_read_only | Parses /sys/class/hwmon and returns the found hwmons as a Hwmons object. |
parse_hwmons_read_write | Parses /sys/class/hwmon and returns the found hwmons as a Hwmons object. Be sure you have sufficient rights to write to your sensors. Usually only root has those rights. |