[][src]Struct battery::Battery

pub struct Battery(_);

Battery instant information representation.

Consequent calls of the same method will return the same value.

Methods

impl Battery[src]

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

The amount of energy left in the battery expressed as a percentage between 0.0 and 100.0.

pub fn energy(&self) -> u32[src]

Amount of energy (measured in mWh) currently available in the battery.

pub fn energy_full(&self) -> u32[src]

Amount of energy (measured in mWh) in the battery when it's considered full.

pub fn energy_full_design(&self) -> u32[src]

Amount of energy (measured in mWh) the battery is designed to hold when it's considered full.

pub fn energy_rate(&self) -> u32[src]

Amount of energy being drained from the battery, measured in mW.

pub fn voltage(&self) -> u32[src]

Gets a battery voltage (in mV).

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

Gets battery capacity in 0.0..100.0 percents range.

pub fn state(&self) -> State[src]

Gets battery current state.

See State enum for possible values.

pub fn technology(&self) -> Technology[src]

Gets battery technology.

See Technology enum for possible values.

Compatibility

  • For MacOS this method always returns None. This behavior might change later.

pub fn temperature(&self) -> Option<f32>[src]

Gets battery temperature in Celsius degrees.

Compatibility

Not all device drivers are providing this value, therefore callers should not expect to have some all the time.

pub fn cycle_count(&self) -> Option<u32>[src]

Number of charge/discharge cycles

pub fn vendor(&self) -> Option<&str>[src]

Gets battery vendor.

pub fn model(&self) -> Option<&str>[src]

Gets battery model.

pub fn serial_number(&self) -> Option<&str>[src]

Gets battery serial number.

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

Gets a remaining time till full battery.

This is an instant value and may different vastly from call to call. Any aggregation should be made by caller.

If battery is not charging at the moment, this method will return None.

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

Gets a remaining time till empty battery.

This is an instant value and may different vastly from call to call. Any aggregation should be made by caller.

If battery is not discharging at the moment, this method will return None.

Trait Implementations

impl Debug for Battery[src]

Auto Trait Implementations

impl Send for Battery

impl Sync for Battery

Blanket Implementations

impl<T> From for T[src]

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

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

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

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

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

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

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

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.