[][src]Struct macsmc::BatteryDetail

pub struct BatteryDetail {
    pub cycles: u32,
    pub current_capacity: MilliAmpereHours,
    pub full_capacity: MilliAmpereHours,
    pub amperage: MilliAmpere,
    pub voltage: Volt,
    pub power: Watt,
}

Various information about the battery in detail

Fields

cycles: u32

The number of charging cycles of the battery

current_capacity: MilliAmpereHours

The current capacity ("charge") of the battery

full_capacity: MilliAmpereHours

The capacity ("charge") of the battery if it was at 100%. This is different from the intial design capacity. It naturally decreases over the lifetime of the battery, meaning that older batteries cannot hold as much charge anyumore.

amperage: MilliAmpere

The Current (amperage) on this battery Named amperage instead of current to prevent confusion with "current charge".

voltage: Volt

The voltage on this battery

power: Watt

If this is a positive value, it's the power delivered of this battery. If this is a negative value, it's the rate at which this battery is being charged.

Implementations

impl BatteryDetail[src]

pub fn percentage(&self) -> f32[src]

The current charge as a percentage. Value is between 0.0 and 100.0

Examples

let battery = BatteryDetail {
    current_capacity: MilliAmpereHours(1000),
    full_capacity: MilliAmpereHours(5000),
    ..BatteryDetail::default()
};

assert_eq!(battery.percentage(), 20.0);

pub fn time_remaining(&self) -> Option<Duration>[src]

How much time is remaining on battery, based on the current current (amperage). This is not checking if the system is marked as being "powered by battery". This only operates based on the value of amperage. Returns None if the battery is draining.

pub fn time_until_full(&self) -> Option<Duration>[src]

How long it will take to load the battery based on the current current (amperage). This is not checking if the battery is marked as "being charged". This only operates based on the value of amperage. Returns None if the battery is not charging.

Trait Implementations

impl Clone for BatteryDetail[src]

impl Copy for BatteryDetail[src]

impl Debug for BatteryDetail[src]

impl Default for BatteryDetail[src]

impl PartialEq<BatteryDetail> for BatteryDetail[src]

impl StructuralPartialEq for BatteryDetail[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.