AppEventEmitter

Trait AppEventEmitter 

Source
pub trait AppEventEmitter: Send + Sync {
    // Required methods
    fn emit(&self, event: AppEvent);
    fn clone_box(&self) -> Box<dyn AppEventEmitter>;
}
Expand description

Trait for emitting application events.

This abstraction keeps event plumbing consistent across domains and prevents channel types from becoming part of the public API surface.

§Implementations

  • NoopEmitter - For tests and CLI contexts that don’t need events
  • Adapter-specific implementations (Tauri, Axum SSE, etc.)

§Example

// In a service
fn start_server(&self, emitter: Arc<dyn AppEventEmitter>) {
    // ... start server logic ...
    emitter.emit(AppEvent::McpServerStarted { ... });
}

Required Methods§

Source

fn emit(&self, event: AppEvent)

Emit an application event.

Implementations should handle the event asynchronously or buffer it. This method should not block.

Source

fn clone_box(&self) -> Box<dyn AppEventEmitter>

Clone this emitter into a boxed trait object.

This enables cloning of Arc<dyn AppEventEmitter> without requiring the underlying type to implement Clone.

Implementors§