use std::convert::Infallible;
use uuid::Uuid;
use crate::client::{DeviceBase, HlapiClient, HlapiClientError};
#[derive(Debug, Clone)]
pub struct Beacon {
client: HlapiClient,
uuid: Uuid,
}
impl Beacon {
pub fn get_levels(&self) -> Result<u8, HlapiClientError> {
Ok(self.call("getLevels", &[], &[])?.0)
}
pub fn get_primary_effect(&self) -> Result<Option<String>, HlapiClientError> {
Ok(self.call("getPrimaryEffect", &[], &[])?.0)
}
pub fn get_secondary_effect(&self) -> Result<Option<String>, HlapiClientError> {
Ok(self.call("getSecondaryEffect", &[], &[])?.0)
}
}
impl DeviceBase for Beacon {
const TYPE: &'static str = "beacon";
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
}
}