steer_core/app/io.rs
1use crate::error::Result;
2use async_trait::async_trait;
3use tokio::sync::mpsc;
4
5use super::{AppCommand, AppEvent};
6
7/// Abstraction over a channel or transport that accepts `AppCommand`s sent
8/// from the UI or other front-ends.
9#[async_trait]
10pub trait AppCommandSink: Send + Sync {
11 /// Send a command to the application core.
12 async fn send_command(&self, command: AppCommand) -> Result<()>;
13}
14
15/// Source of [`AppEvent`]s produced by the application core that front-ends can
16/// listen to for UI updates.
17///
18/// Implementations typically wrap an `mpsc::Receiver<AppEvent>` or forward
19/// events from an external transport (e.g. gRPC stream).
20#[async_trait]
21pub trait AppEventSource: Send + Sync {
22 /// Obtain a receiver that yields application events. A fresh receiver
23 /// should be returned on every call so multiple consumers can coexist.
24 async fn subscribe(&self) -> mpsc::Receiver<AppEvent>;
25}