pub enum Message {
System(SystemMessage),
User(UserMessage),
Assistant(AssistantMessage),
Result(ResultMessage),
StreamEvent(StreamEvent),
RateLimitEvent(RateLimitEvent),
}Expand description
A single NDJSON message read from the Claude CLI stdout.
Deserialized via #[serde(tag = "type")] so the "type" field selects
the variant.
Variants§
System(SystemMessage)
Session metadata emitted once at the start.
User(UserMessage)
Echo of a user turn (our input reflected back).
Assistant(AssistantMessage)
A model response turn.
Result(ResultMessage)
Final summary after the conversation completes.
StreamEvent(StreamEvent)
A raw API streaming event (only when --include-partial-messages).
RateLimitEvent(RateLimitEvent)
Rate limit status information.
Implementations§
Source§impl Message
impl Message
Sourcepub fn is_result(&self) -> bool
pub fn is_result(&self) -> bool
Returns true if this is a ResultMessage.
Sourcepub fn is_stream_event(&self) -> bool
pub fn is_stream_event(&self) -> bool
Returns true if this is a StreamEvent.
Sourcepub fn is_assistant(&self) -> bool
pub fn is_assistant(&self) -> bool
Returns true if this is an AssistantMessage.
Sourcepub fn as_assistant(&self) -> Option<&AssistantMessage>
pub fn as_assistant(&self) -> Option<&AssistantMessage>
Try to extract a reference to the inner AssistantMessage.
Sourcepub fn as_result(&self) -> Option<&ResultMessage>
pub fn as_result(&self) -> Option<&ResultMessage>
Try to extract a reference to the inner ResultMessage.
Sourcepub fn as_stream_event(&self) -> Option<&StreamEvent>
pub fn as_stream_event(&self) -> Option<&StreamEvent>
Try to extract a reference to the inner StreamEvent.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Message
impl<'de> Deserialize<'de> for Message
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 Message
impl RefUnwindSafe for Message
impl Send for Message
impl Sync for Message
impl Unpin for Message
impl UnsafeUnpin for Message
impl UnwindSafe for Message
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