use std::convert::Infallible;
use uuid::Uuid;
use crate::client::{DeviceBase, HlapiClient, HlapiClientError};
#[derive(Debug, Clone)]
pub struct EnergyStorage {
client: HlapiClient,
uuid: Uuid,
}
impl EnergyStorage {
pub fn can_extract_energy(&self) -> Result<bool, HlapiClientError> {
Ok(self.call("canExtractEnergy", &[], &[])?.0)
}
pub fn can_receive_energy(&self) -> Result<bool, HlapiClientError> {
Ok(self.call("canReceiveEnergy", &[], &[])?.0)
}
pub fn get_energy_stored(&self) -> Result<u32, HlapiClientError> {
Ok(self.call("getEnergyStored", &[], &[])?.0)
}
pub fn get_max_energy_stored(&self) -> Result<u32, HlapiClientError> {
Ok(self.call("getMaxEnergyStored", &[], &[])?.0)
}
}
impl DeviceBase for EnergyStorage {
const TYPE: &'static str = "energy_storage";
type Event = Infallible;
fn new(client: HlapiClient, uuid: Uuid) -> Result<Self, HlapiClientError> {
Ok(Self { client, uuid })
}
fn uuid_base(&self) -> Uuid {
self.uuid
}
fn client(&self) -> &HlapiClient {
&self.client
}
}