pub trait EventHandler: Send {
// Provided methods
fn on_text(&mut self, text: &str) { ... }
fn on_tool_use(&mut self, tool: &str, input: &Value) { ... }
fn on_tool_result(&mut self, result: &str) { ... }
fn on_error(&mut self, error: &str) { ... }
fn on_complete(&mut self) { ... }
}Expand description
Event handler trait for streaming responses.
Implement this trait to handle streaming events from Claude during task execution or interactive sessions.
All methods have default no-op implementations, allowing you to override only the events you care about.
Provided Methods§
Sourcefn on_tool_use(&mut self, tool: &str, input: &Value)
fn on_tool_use(&mut self, tool: &str, input: &Value)
Called when Claude starts using a tool.
§Arguments
tool- The name of the tool being usedinput- The input parameters for the tool
Sourcefn on_tool_result(&mut self, result: &str)
fn on_tool_result(&mut self, result: &str)
Sourcefn on_complete(&mut self)
fn on_complete(&mut self)
Called when the response is complete.