pub enum Event {
System(SystemMessage),
User(UserMessage),
Assistant {
message: AssistantMessage,
tool_uses: Vec<ToolUse>,
},
Result(ResultMessage),
Stream {
raw: StreamEvent,
assembled: Vec<AssembledEvent>,
},
RateLimit(RateLimitEvent),
}Expand description
A high-level event from a Claude session.
This is the primary type that callers iterate over via
Session::next_event.
Variants§
System(SystemMessage)
A system metadata message (emitted once at session start).
User(UserMessage)
An echo of a user turn.
Assistant
An assistant response turn.
The tool_uses field is pre-extracted for convenience — it contains
the same tool-use blocks that appear in message.content, but as
ToolUse structs for easier pattern matching.
Fields
message: AssistantMessageThe full assistant message.
Result(ResultMessage)
The final result message (session complete).
Stream
A raw streaming event with assembled content.
Only emitted when include_partial_messages is set in SessionOptions.
Fields
raw: StreamEventThe raw streaming event from the API.
assembled: Vec<AssembledEvent>Events assembled by the StreamAssembler.
RateLimit(RateLimitEvent)
Rate limit status information.
Implementations§
Source§impl Event
impl Event
Sourcepub fn is_result(&self) -> bool
pub fn is_result(&self) -> bool
Returns true if this is a Event::Result (session complete).
Sourcepub fn is_assistant(&self) -> bool
pub fn is_assistant(&self) -> bool
Returns true if this is an Event::Assistant variant.
Sourcepub fn tool_uses(&self) -> Option<&[ToolUse]>
pub fn tool_uses(&self) -> Option<&[ToolUse]>
If this is an Event::Assistant with tool-use requests, return them.
Sourcepub fn as_result(&self) -> Option<&ResultMessage>
pub fn as_result(&self) -> Option<&ResultMessage>
If this is a Event::Result, return a reference to the result message.