[−][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:
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):
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:
use battery::units::ratio::percent; for bat in battery::Manager::new()?.batteries()? { println!("State of charge: {} %", bat?.state_of_charge().get::<percent>()); }
or time:
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 |
|
ElectricCurrent |
|
ElectricPotential |
|
Energy |
|
Power |
|
Ratio |
|
ThermodynamicTemperature |
|
Time |
|