pub struct Sensor {
Show 16 fields pub name: String, dbuspath: Arc<SensorPath>, pub kind: SensorType, poll_interval: Duration, pub power_state: PowerState, pub thresholds: [Option<Threshold>; 5], scale: f64, errcount: usize, cache: SignalProp<f64>, minvalue: SignalProp<f64>, maxvalue: SignalProp<f64>, available: SignalProp<bool>, functional: SignalProp<bool>, associations: SignalProp<Vec<(String, String, String)>>, mode: SensorMode, iotask: Option<SensorIOTask>,
}
Expand description

The top-level representation of a sensor.

Fields

name: String

The globally-unique name of the sensor.

dbuspath: Arc<SensorPath>

The dbus path of the sensor object.

kind: SensorType

The type of the sensor.

poll_interval: Duration

The period of the sensor polling loop.

power_state: PowerState

The host power state in which this sensor is enabled.

thresholds: [Option<Threshold>; 5]

Threshold values (warning, critical, etc.) for the sensor.

scale: f64

A multiplicative scaling factor for readings from the sensor.

This is only the config-specified scaling factor (converted to a multiplier); scaling to convert sysfs hwmon values to the desired units (e.g. 0.001 to convert a sysfs millivolt value to volts) happens elsewhere.

errcount: usize

The number of failed update attempts since the last successful one.

cache: SignalProp<f64>

The dbus property that provides the sensor’s value.

minvalue: SignalProp<f64>

The dbus property that provides the sensor’s minimum value.

maxvalue: SignalProp<f64>

The dbus property that provides the sensor’s maximum value.

available: SignalProp<bool>

The dbus property that provides the sensor’s availability state.

functional: SignalProp<bool>

The dbus property that provides the sensor’s functionality state.

associations: SignalProp<Vec<(String, String, String)>>

The dbus property that provides the sensor’s associations.

mode: SensorMode

The sensor’s dbus RO/RW mode.

iotask: Option<SensorIOTask>

The sensor’s running I/O task.

This is Some when the sensor is active and None when it’s inactive (e.g. when the host’s current power state doesn’t match the sensor’s power_state).

Implementations

Construct a new Sensor with the given parameters.

It will initially be disabled (no running I/O task); it can subsequently be enabled by a call to its activate() method.

Set the sensor’s poll_interval.

Set the sensor’s power_state.

Set the sensor’s thresholds.

The thresholds are constructed from the provided config data, interfaces, and dbus connection.

Set the sensor’s scale.

Set the sensor’s maxvalue.

Set the sensor’s minvalue.

Set the sensor’s cached value and update the state of its thresholds.

Start a sensor’s update task using the provided ioctx and mark it available.

This is an associated function rather than a method on self because it needs to pass a weak reference to itself into the future that gets spawned as Sensor::iotask, and we need an Arc for that.

Stop a sensor’s update task and mark it unavailable.

Publish a sensor’s properties on dbus.

cbdata must contain self. (Perhaps this should instead be an associated function that just takes that instead of both separately.)

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.