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) = { if let Some(level_percent) = battery_info.level() { // Report to peer. } }


Manages the connection to the Fuchsia BatteryManager service.


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


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