Skip to content

Commit

Permalink
ComponentExt: Add document to Linux details.
Browse files Browse the repository at this point in the history
  • Loading branch information
darnuria committed Sep 2, 2022
1 parent 6eb0716 commit 8e95cf8
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1486,10 +1486,17 @@ pub trait ComponentExt: Debug {
/// println!("{}°C", component.temperature());
/// }
/// ```
///
/// ## Linux
///
/// Returns `f32::NAN` if it failed to retrieve it.
fn temperature(&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.
///
/// ```no_run
/// use sysinfo::{ComponentExt, System, SystemExt};
///
Expand All @@ -1498,6 +1505,11 @@ pub trait ComponentExt: Debug {
/// println!("{}°C", component.max());
/// }
/// ```
///
/// ## Linux
///
/// May be computed by sysinfo from kernel.
/// Returns `f32::NAN` if it failed to retrieve it.
fn max(&self) -> f32;

/// Returns the highest temperature before the component halts (in celsius degree).
Expand All @@ -1510,6 +1522,10 @@ pub trait ComponentExt: Debug {
/// println!("{:?}°C", component.critical());
/// }
/// ```
///
/// ## Linux
///
/// Critical threshold defined by chip or kernel.
fn critical(&self) -> Option<f32>;

/// Returns the label of the component.
Expand All @@ -1522,6 +1538,19 @@ pub trait ComponentExt: Debug {
/// 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.
///
/// | name | label | device_model | id_sensor | Computed label by `sysinfo` |
/// |---------|--------|------------|----------|----------------------|
/// | ✓ | ✓ | ✓ | ✓ | `"{name} {label} {device_model} temp{id}"` |
/// | ✓ | ✓ | ✗ | ✓ | `"{name} {label} {id}"` |
/// | ✓ | ✗ | ✓ | ✓ | `"{name} {device_model}"` |
/// | ✓ | ✗ | ✗ | ✓ | `"{name} temp{id}"` |
fn label(&self) -> &str;

/// Refreshes component.
Expand Down

0 comments on commit 8e95cf8

Please sign in to comment.