use std::sync::Arc;
use async_trait::async_trait;
use freshblu_core::message::DeviceEvent;
use tokio::sync::broadcast;
use uuid::Uuid;
#[async_trait]
pub trait MessageBus: Send + Sync + 'static {
async fn publish(&self, target: &Uuid, event: DeviceEvent) -> anyhow::Result<()>;
async fn publish_many(&self, targets: &[Uuid], event: DeviceEvent) -> anyhow::Result<()>;
fn connect(&self, uuid: Uuid) -> broadcast::Receiver<DeviceEvent>;
fn disconnect(&self, uuid: &Uuid);
fn is_online(&self, uuid: &Uuid) -> bool;
fn online_count(&self) -> usize;
}
pub type DynBus = Arc<dyn MessageBus>;