Converted google home traits to be async
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2023-08-11 03:46:44 +02:00
parent a67e47997b
commit 522fe27f11
8 changed files with 60 additions and 38 deletions

View File

@@ -1,3 +1,4 @@
use async_trait::async_trait;
use serde::Serialize;
use crate::errors::ErrorCode;
@@ -10,6 +11,7 @@ pub enum Trait {
Scene,
}
#[async_trait]
#[impl_cast::device_trait]
pub trait OnOff {
fn is_command_only(&self) -> Option<bool> {
@@ -21,15 +23,16 @@ pub trait OnOff {
}
// TODO: Implement correct error so we can handle them properly
fn is_on(&self) -> Result<bool, ErrorCode>;
fn set_on(&mut self, on: bool) -> Result<(), ErrorCode>;
async fn is_on(&self) -> Result<bool, ErrorCode>;
async fn set_on(&mut self, on: bool) -> Result<(), ErrorCode>;
}
#[async_trait]
#[impl_cast::device_trait]
pub trait Scene {
fn is_scene_reversible(&self) -> Option<bool> {
None
}
fn set_active(&self, activate: bool) -> Result<(), ErrorCode>;
async fn set_active(&self, activate: bool) -> Result<(), ErrorCode>;
}