Trait sysinfo::ComponentExt

source ·
pub trait ComponentExt: Debug {
    // Required methods
    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§

source

fn temperature(&self) -> f32

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.

source

fn max(&self) -> f32

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.

source

fn critical(&self) -> Option<f32>

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.

source

fn label(&self) -> &str

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 information is 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}"
source

fn refresh(&mut self)

Refreshes component.

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

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

Implementors§