Skip to main content

Module sensors

Module sensors 

Source
Expand description

Temperatures.

Only documented, unprivileged sources are read. Linux has them for most sensors (hwmon, thermal zones); Windows has them for NVMe drives only, and macOS for none (Apple silicon sensors need private HID APIs and Intel SMC keys are undocumented), so both answer what they can and nothing else. Inside Docker and WSL the sensors are usually hidden: an empty list, not an error.

use sys_lib as sys;

match sys::sensors::temperatures() {
    Ok(list) => {
        for t in list {
            println!("{:<16} {:?} {:.1} C (critical {:?})", t.label, t.kind, t.celsius, t.critical);
        }
    }
    Err(e) if e.is_unavailable() => println!("no temperatures here"),
    Err(e) => return Err(e),
}

Structs§

Temperature
One temperature sensor.

Enums§

SensorKind
What a sensor measures.

Functions§

temperatures
Every temperature the OS reports without privileges, in the order it lists them. Readings outside -60 to 250 degrees are left out: they are absent sensors that report a placeholder.