Trait sysinfo::ComponentExt

source ·
pub trait ComponentExt: Debug {
    fn temperature(&self) -> f32;
    fn max(&self) -> f32;
    fn critical(&self) -> Option<f32>;
    fn label(&self) -> &str;
    fn refresh(&mut self);
}
Expand description

Getting a component temperature information.

Required Methods§

Returns the temperature of the component (in celsius degree).

use sysinfo::{ComponentExt, System, SystemExt};

let s = System::new_all();
for component in s.components() {
    println!("{}°C", component.temperature());
}
Linux

Returns f32::NAN if it failed to retrieve it.

Returns the maximum temperature of the component (in celsius degree).

Note: if temperature is higher than the current max, max value will be updated on refresh.

use sysinfo::{ComponentExt, System, SystemExt};

let s = System::new_all();
for component in s.components() {
    println!("{}°C", component.max());
}
Linux

May be computed by sysinfo from kernel. Returns f32::NAN if it failed to retrieve it.

Returns the highest temperature before the component halts (in celsius degree).

use sysinfo::{ComponentExt, System, SystemExt};

let s = System::new_all();
for component in s.components() {
    println!("{:?}°C", component.critical());
}
Linux

Critical threshold defined by chip or kernel.

Returns the label of the component.

use sysinfo::{ComponentExt, System, SystemExt};

let s = System::new_all();
for component in s.components() {
    println!("{}", component.label());
}
Linux

Since components informations are retrieved thanks to hwmon, the labels are generated as follows. Note: it may change and it was inspired by sensors own formatting.

namelabeldevice_modelid_sensorComputed label by sysinfo
"{name} {label} {device_model} temp{id}"
"{name} {label} {id}"
"{name} {device_model}"
"{name} temp{id}"

Refreshes component.

use sysinfo::{ComponentExt, System, SystemExt};

let mut s = System::new_all();
for component in s.components_mut() {
    component.refresh();
}

Implementors§