Skip to main content

Emitter

Trait Emitter 

Source
pub trait Emitter:
    Send
    + Sync
    + Debug {
    // Required methods
    fn emit_output(&self, message: &str);
    fn emit_output_with_level(&self, message: &str, level: &str);
    fn clone_box(&self) -> Box<dyn Emitter>;

    // Provided methods
    fn emit_event(
        &self,
        _category: &str,
        _operation: &str,
        _payload: Value,
    ) -> bool { ... }
    fn board_recent(&self, _n: usize) -> Vec<Value> { ... }
    fn request(
        &self,
        _target: &str,
        _operation: &str,
        _payload: Value,
        _timeout_ms: Option<u64>,
    ) -> Result<Value, String> { ... }
    fn is_alive(&self, _target_fqn: &str) -> bool { ... }
}
Expand description

Trait for emitting events from Components.

Components receive an implementation of this trait via Component::set_emitter.

The emitter allows Components to:

  • Send output to the user (via IO)
  • Broadcast signals to other Components

Required Methods§

Source

fn emit_output(&self, message: &str)

Emits an output message (info level).

The message will be displayed to the user via IOBridge.

Source

fn emit_output_with_level(&self, message: &str, level: &str)

Emits an output message with a specific level.

§Arguments
  • message - The message to display
  • level - Log level (“info”, “warn”, “error”)
Source

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

Clones the emitter into a boxed trait object.

This allows storing the emitter in the Component.

Provided Methods§

Source

fn emit_event(&self, _category: &str, _operation: &str, _payload: Value) -> bool

Emits a custom event (broadcast to all channels).

Creates an Extension event with the given category and broadcasts it to all registered channels. Channels subscribed to the matching Extension category will process it.

§Arguments
  • category - Extension kind string (e.g., “tool:result”)
  • operation - Operation name (e.g., “complete”)
  • payload - Event payload data
§Returns

true if the event was broadcast successfully.

Source

fn board_recent(&self, _n: usize) -> Vec<Value>

Returns the most recent n Board entries as JSON values.

The Board is a shared rolling buffer of recent Output and Extension events. Components can query it to see what other components have emitted recently.

Default implementation returns an empty vec (no board attached).

§Arguments
  • n - Maximum number of entries to return
Source

fn request( &self, _target: &str, _operation: &str, _payload: Value, _timeout_ms: Option<u64>, ) -> Result<Value, String>

Sends a synchronous RPC request to another Component.

Routes via EventBus to the target Component’s on_request handler and returns the response. Blocks the calling thread until response is received or timeout expires.

§Arguments
  • target - Target Component name (e.g., “skill-manager”)
  • operation - Operation name (e.g., “list”, “activate”)
  • payload - Request payload
  • timeout_ms - Optional timeout override (default: 30s)
§Returns

Response value from the target Component, or error string.

§Default Implementation

Returns error (not supported without runtime wiring).

Source

fn is_alive(&self, _target_fqn: &str) -> bool

Checks whether a target Component is alive (its runner is still running).

Uses the EventBus channel handle to determine liveness without sending a request. This is a best-effort check — the component may die immediately after returning true (TOCTOU inherent in concurrent systems).

§Arguments
  • target_fqn - Fully qualified name or short name of the target Component
§Default Implementation

Returns false (no runtime wiring available).

Trait Implementations§

Source§

impl Clone for Box<dyn Emitter>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Implementors§