[][src]Module battery::units

Partially re-exported uom quantities and measurement units used in the library public interface.

Public methods for Battery are returning these types.
Internally values in these types are stored as a SI measurement units, so, for example, if you want to get the battery energy in the watt·hour units instead of the default joules, you will need the measurement unit from the corresponding module:

This code runs with edition 2018
use battery::units::energy::watt_hour;

for bat in battery::Manager::new()?.batteries()? {
    println!("Energy: {} Wh", bat?.energy().get::<watt_hour>());
}

Same thing applies to other units (temperature is stored in Kelvins):

This code runs with edition 2018
use battery::units::thermodynamic_temperature::degree_celsius;

for bat in battery::Manager::new()?.batteries()? {
    if let Some(value) = bat?.temperature() {
        println!("Temperature: {} °C", value.get::<degree_celsius>());
    }
}

percents:

This code runs with edition 2018
use battery::units::ratio::percent;

for bat in battery::Manager::new()?.batteries()? {
    println!("State of charge: {} %", bat?.state_of_charge().get::<percent>());
}

or time:

This code runs with edition 2018
use std::time::Duration;

use battery::units::time::nanosecond;

for bat in battery::Manager::new()?.batteries()? {
    if let Some(value) = bat?.time_to_full() {
        let duration = Duration::from_nanos(value.get::<nanosecond>() as u64);
    }
}

Modules

electric_charge

Electric charge (base unit coulomb, A · s).

electric_current

Electric current (base unit ampere, A).

electric_potential

Electric potential (base unit volt, m² · kg · s⁻³ · A⁻¹).

energy

Energy (base unit joule, kg · m² · s⁻²).

power

Power (base unit watt, m² · kg · s⁻³).

ratio

Ratio (dimensionless quantity).

thermodynamic_temperature

Thermodynamic temperature (base unit kelvin, K).

time

Time (base unit second, s).

Traits

Unit

Trait to identify measurement units of individual quantities.

Type Definitions

ElectricCharge

Quantity type alias using the default base units.

ElectricCurrent

Quantity type alias using the default base units.

ElectricPotential

Quantity type alias using the default base units.

Energy

Quantity type alias using the default base units.

Power

Quantity type alias using the default base units.

Ratio

Quantity type alias using the default base units.

ThermodynamicTemperature

Quantity type alias using the default base units.

Time

Quantity type alias using the default base units.