use anyhow::Result;
use async_trait::async_trait;
use serde::{Deserialize, Serialize};
use serde_json::Value;
#[async_trait]
pub trait DaemonService: Send + Sync {
fn name(&self) -> &'static str;
async fn handle(&self, op: &str, payload: Value) -> Result<Value>;
fn menu(&self) -> MenuSnapshot;
async fn menu_action(&self, action_id: &str) -> Result<()>;
async fn status(&self) -> ServiceStatus;
async fn shutdown(&self);
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ServiceStatus {
pub name: String,
pub healthy: bool,
pub summary: String,
#[serde(default, skip_serializing_if = "Value::is_null")]
pub detail: Value,
}
#[derive(Debug, Clone, Default)]
pub struct MenuSnapshot {
pub title: String,
pub items: Vec<MenuItem>,
}
#[derive(Debug, Clone)]
pub enum MenuItem {
Label(String),
Separator,
Action(MenuAction),
}
#[derive(Debug, Clone)]
pub struct MenuAction {
pub id: String,
pub label: String,
pub enabled: bool,
}