use std::fmt;
use std::time::Duration;
use crate::{State, Technology};
use crate::types::Device;
use crate::platform::BatteryDevice;
pub struct Battery(BatteryDevice);
impl Battery {
pub fn state(&self) -> State {
self.0.state()
}
pub fn technology(&self) -> Technology {
self.0.technology()
}
pub fn vendor(&self) -> Option<&str> {
self.0.vendor()
}
pub fn model(&self) -> Option<&str> {
self.0.model()
}
pub fn serial_number(&self) -> Option<&str> {
self.0.serial_number()
}
pub fn capacity(&self) -> f64 {
self.0.capacity()
}
pub fn temperature(&self) -> f64 {
self.0.temperature()
}
pub fn percentage(&self) -> f64 {
self.0.percentage()
}
pub fn energy(&self) -> f64 {
self.0.energy()
}
pub fn energy_full(&self) -> f64 {
self.0.energy_full()
}
pub fn energy_full_design(&self) -> f64 {
self.0.energy_full_design()
}
pub fn energy_rate(&self) -> f64 {
self.0.energy_rate()
}
pub fn voltage(&self) -> f64 {
self.0.voltage()
}
pub fn time_to_full(&self) -> Option<Duration> {
self.0.time_to_full()
}
pub fn time_to_empty(&self) -> Option<Duration> {
self.0.time_to_empty()
}
}
impl fmt::Debug for Battery {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("Battery")
.field("vendor", &self.vendor())
.field("model", &self.model())
.field("serial_number", &self.serial_number())
.field("technology", &self.technology())
.field("state", &self.state())
.field("capacity", &self.capacity())
.field("temperature", &self.temperature())
.field("percentage", &self.percentage())
.field("energy", &self.energy())
.field("energy_full", &self.energy_full())
.field("energy_full_design", &self.energy_full_design())
.field("energy_rate", &self.energy_rate())
.field("voltage", &self.voltage())
.field("time_to_full", &self.time_to_full())
.field("time_to_empty", &self.time_to_empty())
.finish()
}
}
impl From<BatteryDevice> for Battery {
fn from(inner: BatteryDevice) -> Self {
Battery(inner)
}
}