Skip to main content

MessageWriter

Trait MessageWriter 

Source
pub trait MessageWriter: Send + Sync {
    // Required methods
    fn broadcast(&self, content: &str) -> BoxFuture<'_, Result<()>>;
    fn reply_to(
        &self,
        username: &str,
        content: &str,
    ) -> BoxFuture<'_, Result<()>>;
    fn emit_event(
        &self,
        event_type: EventType,
        content: &str,
        params: Option<Value>,
    ) -> BoxFuture<'_, Result<()>>;
}
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) -> BoxFuture<'_, Result<()>>

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

Source

fn reply_to(&self, username: &str, content: &str) -> BoxFuture<'_, Result<()>>

Send a private system message only to a specific user.

Source

fn emit_event( &self, event_type: EventType, content: &str, params: Option<Value>, ) -> BoxFuture<'_, Result<()>>

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

Implementors§