use std::fmt::Debug;
use crate::units::{ElectricCharge, ElectricCurrent, ElectricPotential, ThermodynamicTemperature, Time};
use crate::Result;
pub trait DataSource: Debug + 'static {
fn refresh(&mut self) -> Result<()>;
fn fully_charged(&self) -> bool;
fn external_connected(&self) -> bool;
fn is_charging(&self) -> bool;
fn voltage(&self) -> ElectricPotential;
fn amperage(&self) -> ElectricCurrent;
fn design_capacity(&self) -> ElectricCharge;
fn max_capacity(&self) -> ElectricCharge;
fn current_capacity(&self) -> ElectricCharge;
fn temperature(&self) -> Option<ThermodynamicTemperature>;
fn cycle_count(&self) -> Option<u32>;
fn time_remaining(&self) -> Option<Time>;
fn manufacturer(&self) -> Option<&str>;
fn device_name(&self) -> Option<&str>;
fn serial_number(&self) -> Option<&str>;
}
impl<T> DataSource for Box<T>
where
T: DataSource + ?Sized,
{
fn refresh(&mut self) -> Result<()> {
(**self).refresh()
}
fn fully_charged(&self) -> bool {
(**self).fully_charged()
}
fn external_connected(&self) -> bool {
(**self).external_connected()
}
fn is_charging(&self) -> bool {
(**self).is_charging()
}
fn voltage(&self) -> ElectricPotential {
(**self).voltage()
}
fn amperage(&self) -> ElectricCurrent {
(**self).amperage()
}
fn design_capacity(&self) -> ElectricCharge {
(**self).design_capacity()
}
fn max_capacity(&self) -> ElectricCharge {
(**self).max_capacity()
}
fn current_capacity(&self) -> ElectricCharge {
(**self).current_capacity()
}
fn temperature(&self) -> Option<ThermodynamicTemperature> {
(**self).temperature()
}
fn cycle_count(&self) -> Option<u32> {
(**self).cycle_count()
}
fn time_remaining(&self) -> Option<Time> {
(**self).time_remaining()
}
fn manufacturer(&self) -> Option<&str> {
(**self).manufacturer()
}
fn device_name(&self) -> Option<&str> {
(**self).device_name()
}
fn serial_number(&self) -> Option<&str> {
(**self).serial_number()
}
}