use async_trait::async_trait;
#[async_trait]
pub trait DeviceControlHook: Send + Sync {
async fn display_glyph(
&self,
device_type: &str,
device_id: &str,
pattern: &str,
brightness: Option<f32>,
timeout_ms: Option<u32>,
transition: Option<&str>,
) -> anyhow::Result<()>;
async fn connect_device(&self, device_type: &str, device_id: &str) -> anyhow::Result<()>;
async fn disconnect_device(&self, device_type: &str, device_id: &str) -> anyhow::Result<()>;
}
pub struct NoopDeviceControl;
#[async_trait]
impl DeviceControlHook for NoopDeviceControl {
async fn display_glyph(
&self,
device_type: &str,
device_id: &str,
_pattern: &str,
_brightness: Option<f32>,
_timeout_ms: Option<u32>,
_transition: Option<&str>,
) -> anyhow::Result<()> {
tracing::warn!(
device_type,
device_id,
"DisplayGlyph received but no device-control hook is registered"
);
Ok(())
}
async fn connect_device(&self, device_type: &str, device_id: &str) -> anyhow::Result<()> {
tracing::warn!(
device_type,
device_id,
"DeviceConnect received but no device-control hook is registered"
);
Ok(())
}
async fn disconnect_device(&self, device_type: &str, device_id: &str) -> anyhow::Result<()> {
tracing::warn!(
device_type,
device_id,
"DeviceDisconnect received but no device-control hook is registered"
);
Ok(())
}
}