pub struct BatterySnapshot {
pub charge: Percent,
pub state: ChargeState,
pub time_remaining: MetricState<Duration>,
pub cycle_count: MetricState<u32>,
pub capacity: MetricState<BatteryCapacity>,
pub temperature_celsius: MetricState<f32>,
pub power_watts: MetricState<f32>,
}Expand description
Battery state.
Fields§
§charge: PercentCharge level.
state: ChargeStateCharging state.
time_remaining: MetricState<Duration>Time to empty while discharging, or to full while charging.
Only ever what the platform itself reports. §4 forbids deriving one from a single sample: a figure computed from one instantaneous current reading swings by hours between consecutive samples, and a monitor that showed it would be inventing the one number users trust most.
cycle_count: MetricState<u32>Charge cycles, where reported.
capacity: MetricState<BatteryCapacity>Design capacity beside present full-charge capacity, i.e. wear.
temperature_celsius: MetricState<f32>Cell temperature in degrees Celsius, where the pack reports one.
Separate from SensorSnapshot::temperatures because it is not a machine
sensor: it describes the pack, and a battery pack at 45 °C means something
quite different from a CPU package at 45 °C.
power_watts: MetricState<f32>Instantaneous power flowing through the pack, in watts.
A magnitude, never signed. Direction is BatterySnapshot::state’s job:
the sign of Linux’s current_now is driver-dependent, so a signed watt
figure here would mean “out” on one laptop and “in” on the next.
Implementations§
Source§impl BatterySnapshot
impl BatterySnapshot
Sourcepub fn health(&self) -> MetricState<Percent>
pub fn health(&self) -> MetricState<Percent>
Battery health, derived from the capacity pair and from nothing else.
A method rather than a field so there is no way to store a health figure that contradicts the capacities beside it. An unavailable capacity keeps its own reason, so “no capacity reported” and “capacity refused” stay distinguishable on screen (§4).
Trait Implementations§
Source§impl Clone for BatterySnapshot
impl Clone for BatterySnapshot
Source§fn clone(&self) -> BatterySnapshot
fn clone(&self) -> BatterySnapshot
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more