pub trait StreamHandler: Send {
// Required methods
fn on_text(&mut self, text: &str);
fn on_tool_call(&mut self, name: &str, id: &str, input: &Value);
fn on_tool_result(&mut self, id: &str, output: &str);
fn on_error(&mut self, error: &str);
fn on_complete(&mut self, result: &SessionResult);
}Expand description
Handler for streaming output events from Claude.
Implementors receive events as Claude processes and can format/display them in various ways (console output, TUI updates, logging, etc.).
Required Methods§
Sourcefn on_tool_call(&mut self, name: &str, id: &str, input: &Value)
fn on_tool_call(&mut self, name: &str, id: &str, input: &Value)
Called when Claude invokes a tool.
§Arguments
name- Tool name (e.g., “Read”, “Bash”, “Grep”)id- Unique tool invocation IDinput- Tool input parameters as JSON (file paths, commands, patterns, etc.)
Sourcefn on_tool_result(&mut self, id: &str, output: &str)
fn on_tool_result(&mut self, id: &str, output: &str)
Called when a tool returns results.
Sourcefn on_complete(&mut self, result: &SessionResult)
fn on_complete(&mut self, result: &SessionResult)
Called when session completes (verbose only).