use std::{convert::Infallible, num::NonZeroU8};
use uuid::Uuid;
use crate::client::{DeviceBase, HlapiClient, HlapiClientError};
#[derive(Debug, Clone)]
pub struct Lectern {
client: HlapiClient,
uuid: Uuid,
}
impl Lectern {
pub fn get_page(&self) -> Result<u8, HlapiClientError> {
Ok(self.call("getPage", &[], &[])?.0)
}
pub fn get_page_count(&self) -> Result<Option<NonZeroU8>, HlapiClientError> {
let raw = self.call("getPageCount", &[], &[])?.0;
Ok(NonZeroU8::new(raw))
}
}
impl DeviceBase for Lectern {
const TYPE: &'static str = "lectern";
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
}
}