Skip to main content

StreamSink

Trait StreamSink 

Source
pub trait StreamSink: Send + Sync {
    // Required methods
    fn on_text(&self, text: &str);
    fn on_tool_start(&self, tool_name: &str, input: &Value);
    fn on_tool_result(&self, tool_name: &str, result: &ToolResult);
    fn on_error(&self, error: &str);

    // Provided methods
    fn on_thinking(&self, _text: &str) { ... }
    fn on_turn_start(&self, _turn: usize) { ... }
    fn on_turn_complete(&self, _turn: usize) { ... }
    fn on_usage(&self, _usage: &Usage) { ... }
    fn on_compact(&self, _freed_tokens: u64) { ... }
    fn on_warning(&self, _msg: &str) { ... }
}
Expand description

Callback for streaming events to the UI.

Required Methods§

Source

fn on_text(&self, text: &str)

Source

fn on_tool_start(&self, tool_name: &str, input: &Value)

Source

fn on_tool_result(&self, tool_name: &str, result: &ToolResult)

Source

fn on_error(&self, error: &str)

Provided Methods§

Source

fn on_thinking(&self, _text: &str)

Source

fn on_turn_start(&self, _turn: usize)

Called at the start of each agent turn (1-indexed).

Source

fn on_turn_complete(&self, _turn: usize)

Source

fn on_usage(&self, _usage: &Usage)

Source

fn on_compact(&self, _freed_tokens: u64)

Source

fn on_warning(&self, _msg: &str)

Implementors§