pub enum Event {
MessageStart {
message: Message,
},
ContentBlockStart {
index: u32,
content_block: ContentBlock,
},
ContentBlockDelta {
index: u32,
delta: Delta,
},
ContentBlockStop {
index: u32,
},
MessageDelta {
delta: MessageDelta,
usage: Usage,
},
MessageStop,
Ping,
Error {
error: Value,
},
Unknown,
}Expand description
One Anthropic streaming event.
Mirrors the messages streaming wire format as of late 2025.
Unknown event types fall through to Event::Unknown so the parser
never panics on a new event Anthropic adds.
Variants§
MessageStart
Sent first; carries the response shell (id, role, model, initial usage).
ContentBlockStart
A new content block is starting (text, tool_use, thinking, etc.).
Fields
§
content_block: ContentBlockThe (initially empty) content block.
ContentBlockDelta
A delta extending an in-progress content block.
ContentBlockStop
A content block is complete.
MessageDelta
Top-level message delta (final stop_reason, usage so far, etc.).
Fields
§
delta: MessageDeltaWhat changed about the top-level message.
MessageStop
Final event for a message.
Ping
Heartbeat keep-alive; ignore.
Error
Provider-side error; usually means the connection will close.
Unknown
Any event type we don’t know about. Forward-compatible escape hatch.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Event
impl<'de> Deserialize<'de> for Event
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Event
impl RefUnwindSafe for Event
impl Send for Event
impl Sync for Event
impl Unpin for Event
impl UnsafeUnpin for Event
impl UnwindSafe for Event
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more