Improved impl_cast and made all traits Sync + Send + 'static
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2023-04-10 23:51:22 +02:00
parent 65f76904dd
commit b54c9512b9
9 changed files with 77 additions and 66 deletions

View File

@@ -10,7 +10,11 @@ pub enum Trait {
Scene,
}
pub trait OnOff: std::fmt::Debug {
impl_cast::impl_setup!();
impl_cast::impl_cast!(GoogleHomeDevice, OnOff);
impl_cast::impl_cast!(GoogleHomeDevice, Scene);
pub trait OnOff: std::fmt::Debug + Sync + Send + 'static {
fn is_command_only(&self) -> Option<bool> {
None
}
@@ -23,13 +27,11 @@ pub trait OnOff: std::fmt::Debug {
fn is_on(&self) -> Result<bool, ErrorCode>;
fn set_on(&mut self, on: bool) -> Result<(), ErrorCode>;
}
impl_cast::impl_cast!(GoogleHomeDevice, OnOff);
pub trait Scene: std::fmt::Debug {
pub trait Scene: std::fmt::Debug + Sync + Send + 'static {
fn is_scene_reversible(&self) -> Option<bool> {
None
}
fn set_active(&self, activate: bool) -> Result<(), ErrorCode>;
}
impl_cast::impl_cast!(GoogleHomeDevice, Scene);