Crate battery_client

Source
Expand description

A wrapper around the fuchsia.power.battery.BatteryManager capability.

This library provides an API for receiving updates about the current battery information on the local Fuchsia device. A Stream implementation is provided for clients that rely on notification-style updates. Additional methods are also provided to get the most recently received battery information.

§Example Usage:

// Create the BatteryClient. Under the hood, this will connect to the BatteryManager // capability. let batt_client = BatteryClient::create()?;

// Listen for events from the BatteryClient stream implementation. if let Some(battery_info) = batt_client.next().await? { if let Some(level_percent) = battery_info.level() { // Report to peer. } }

Structs§

BatteryClient
Manages the connection to the Fuchsia BatteryManager service.

Enums§

BatteryClientError
BatteryInfo
BatteryLevel
The current battery level, represented as an integer level in the range [MIN_BATTERY_LEVEL, MAX_BATTERY_LEVEL].

Constants§

MAX_BATTERY_LEVEL
The maximum battery level (in %) that will be reported.
MIN_BATTERY_LEVEL
The minimum battery level (in %) that will be reported.