Skip to main content

BatteryCapacity

Struct BatteryCapacity 

Source
pub struct BatteryCapacity {
    pub design_microwatt_hours: u64,
    pub full_microwatt_hours: u64,
}
Expand description

A battery’s design capacity beside the capacity it can hold today.

The pair is one metric rather than two, because the only interesting thing either number does is stand next to the other: 48 Wh means nothing until you know the cell shipped holding 52 Wh. Keeping them together also makes BatteryCapacity::health the only way to obtain a wear percentage, so a health figure can never disagree with the capacities it was derived from.

Micro-watt-hours because that is the unit Linux’s energy_full_design uses; a collector holding amp-hours converts once, at the point it knows the cell voltage, rather than leaving two possible units in the model.

Fields§

§design_microwatt_hours: u64

What the cell held when it left the factory, in µWh.

§full_microwatt_hours: u64

What a full charge holds today, in µWh. This is the worn figure.

Implementations§

Source§

impl BatteryCapacity

Source

pub fn health(self) -> Option<Percent>

Today’s full charge as a share of the design capacity: battery health.

None when the design capacity is zero, which is not 0% health but an unusable pair of numbers (§4). Deliberately not clamped to 100: a cell whose first full charge measures above its design capacity is a real and common reading, and clamping it would hide a working battery behind a suspiciously exact figure.

Trait Implementations§

Source§

impl Clone for BatteryCapacity

Source§

fn clone(&self) -> BatteryCapacity

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for BatteryCapacity

Source§

impl Debug for BatteryCapacity

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for BatteryCapacity

Source§

impl PartialEq for BatteryCapacity

Source§

fn eq(&self, other: &BatteryCapacity) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for BatteryCapacity

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.