use serde_json::Value;
#[derive(Clone, Debug)]
pub struct ScreenProfile {
pub w: u32,
pub h: u32,
pub bit_depth: u8,
pub palette: String,
pub rotation: u16,
}
#[derive(Clone, Debug)]
pub struct DeviceManifest {
pub rev: String,
pub refresh_rate: u32,
pub screen: ScreenProfile,
}
#[derive(Clone, Debug)]
pub struct RenderedImage {
pub bytes: Vec<u8>,
pub content_type: String,
pub rev: String,
}
#[derive(Clone, Debug)]
pub struct SetDeviceResult {
pub dashboard_id: String,
pub refresh_rate: u32,
}
#[derive(Clone, Debug)]
pub struct DeviceBinding {
pub device_id: String,
pub dashboard_id: String,
}
#[async_trait::async_trait]
pub trait DashboardFeed: Send + Sync {
async fn device_manifest(
&self,
device_id: &str,
device_name: &str,
device_type: &str,
prefs: &Value,
) -> Result<DeviceManifest, String>;
async fn device_image(
&self,
device_id: &str,
device_name: &str,
device_type: &str,
prefs: &Value,
known_rev: Option<&str>,
) -> Result<Option<RenderedImage>, String>;
async fn device_config(
&self,
device_id: &str,
device_name: &str,
device_type: &str,
prefs: &Value,
) -> Result<Value, String>;
async fn set_device_config(
&self,
device_id: &str,
device_name: &str,
refresh_rate: Option<u32>,
widgets: Option<Value>,
) -> Result<SetDeviceResult, String>;
async fn delete_device(&self, device_id: &str);
async fn list_bindings(&self) -> Result<Vec<DeviceBinding>, String>;
async fn subscribe_changes(&self) -> tokio::sync::mpsc::Receiver<String>;
}