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 7dc81ca commit c2ca79d
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1486,6 +1486,11 @@ pub trait ComponentExt: Debug {
/// println!("{}°C", component.temperature());
/// }
/// ```
///
/// ## Linux hwmon
///
/// Last temperature reading in case of an errors,
/// returns `f32::NAN`.
fn temperature(&self) -> f32;

/// Returns the maximum temperature of the component (in celsius degree).
Expand All @@ -1498,6 +1503,11 @@ pub trait ComponentExt: Debug {
/// println!("{}°C", component.max());
/// }
/// ```
///
/// ## Linux hwmon
///
/// Read current Maximum value encountered may be computed by sysinfo
/// or from kernel in case of an errors, returns `f32::NAN`.
fn max(&self) -> f32;

/// Returns the highest temperature before the component halts (in celsius degree).
Expand All @@ -1510,6 +1520,13 @@ pub trait ComponentExt: Debug {
/// println!("{:?}°C", component.critical());
/// }
/// ```
///
/// ## Linux hwmon
///
/// Critical threshold defined by chip or kernel may be defined or not.
/// Implementation detail:
///
/// `thresold_critical` is >= `thresold_max`.
fn critical(&self) -> Option<f32>;

/// Returns the label of the component.
Expand All @@ -1522,6 +1539,17 @@ pub trait ComponentExt: Debug {
/// println!("{}", component.label());
/// }
/// ```
///
/// ## Linux hwmon label formating
///
/// It may change. Inspired by `sensors` own formating.
///
/// | 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 All @@ -1534,6 +1562,12 @@ pub trait ComponentExt: Debug {
/// component.refresh();
/// }
/// ```
///
/// ## Linux
///
/// - `temperature` is always read out form `hwmon`.
/// - `max` may kernel provided from `temp*-highest` or computed if
/// `current_temperature` > `max`.
fn refresh(&mut self);
}

Expand Down

0 comments on commit c2ca79d

Please sign in to comment.