Skip to main content

MessageWriter

Trait MessageWriter 

Source
pub trait MessageWriter: Send + Sync {
    // Required methods
    fn broadcast(
        &self,
        content: &str,
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + '_>>;
    fn reply_to(
        &self,
        username: &str,
        content: &str,
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + '_>>;
    fn emit_event(
        &self,
        event_type: EventType,
        content: &str,
        params: Option<Value>,
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + '_>>;
}
Expand description

Async message dispatch for plugins. Abstracts over the broker’s broadcast and persistence machinery so plugins never touch broker internals.

The broker provides a concrete implementation; external crates only see this trait.

Required Methods§

Source

fn broadcast( &self, content: &str, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + '_>>

Broadcast a system message to all connected clients and persist to history.

Source

fn reply_to( &self, username: &str, content: &str, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + '_>>

Send a private system message only to a specific user.

Source

fn emit_event( &self, event_type: EventType, content: &str, params: Option<Value>, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + '_>>

Broadcast a typed event to all connected clients and persist to history.

Implementors§