pub struct BatteryStatus {
pub voltage_mv: Option<u16>,
pub level_percent: Option<u8>,
pub charge_state: Option<BatteryChargeState>,
}Expand description
One battery status snapshot: the fields the platform reports.
None means the field is unsupported (its flag bit is clear). A
snapshot with every field None encodes as the empty value.
Fields§
§voltage_mv: Option<u16>Measured voltage at the battery terminals, in millivolts.
level_percent: Option<u8>Estimated state of charge, 0–100 percent.
charge_state: Option<BatteryChargeState>Charge state reported by the charging system.
Implementations§
Source§impl BatteryStatus
impl BatteryStatus
Sourcepub fn encode(&self, out: &mut [u8]) -> Result<usize, BatteryError>
pub fn encode(&self, out: &mut [u8]) -> Result<usize, BatteryError>
Encode the snapshot, returning the number of bytes written.
An all-None snapshot encodes as zero bytes (the empty form). A
level above 100 is rejected as BatteryError::Malformed.
Sourcepub fn decode(value: &[u8]) -> Result<Self, BatteryError>
pub fn decode(value: &[u8]) -> Result<Self, BatteryError>
Strictly decode a property value.
The empty value decodes to an all-None snapshot. Any other value
must consist of exactly the flags octet and the fields it declares;
a zero flags octet, reserved bits, trailing bytes, a level above
100, and unknown charge-state codes are all malformed.
Trait Implementations§
Source§impl Clone for BatteryStatus
impl Clone for BatteryStatus
Source§fn clone(&self) -> BatteryStatus
fn clone(&self) -> BatteryStatus
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for BatteryStatus
impl Debug for BatteryStatus
Source§impl Default for BatteryStatus
impl Default for BatteryStatus
Source§fn default() -> BatteryStatus
fn default() -> BatteryStatus
Source§impl PartialEq for BatteryStatus
impl PartialEq for BatteryStatus
impl Copy for BatteryStatus
impl Eq for BatteryStatus
impl StructuralPartialEq for BatteryStatus
Auto Trait Implementations§
impl Freeze for BatteryStatus
impl RefUnwindSafe for BatteryStatus
impl Send for BatteryStatus
impl Sync for BatteryStatus
impl Unpin for BatteryStatus
impl UnwindSafe for BatteryStatus
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)