houseflow_device/devices/
mod.rs

1mod light;
2
3pub use light::Light;
4
5use async_trait::async_trait;
6use houseflow_types::{DeviceCommand, DeviceError, DeviceStatus};
7
8pub trait ExecuteParams: serde::de::DeserializeOwned {}
9
10#[async_trait]
11pub trait Device<EP>
12where
13    EP: ExecuteParams,
14{
15    async fn on_execute(
16        &mut self,
17        command: DeviceCommand,
18        params: EP,
19    ) -> anyhow::Result<(DeviceStatus, DeviceError)>;
20
21    fn state(&self) -> serde_json::Value;
22}