#[non_exhaustive]pub enum Message {
User {
message: UserMessage,
},
Assistant {
message: AssistantMessage,
},
System {
subtype: String,
data: Value,
},
Result {
subtype: String,
duration_ms: i64,
duration_api_ms: i64,
is_error: bool,
num_turns: i32,
session_id: String,
total_cost_usd: Option<f64>,
usage: Option<Value>,
result: Option<String>,
structured_output: Option<Value>,
stop_reason: Option<String>,
},
StreamEvent {
uuid: String,
session_id: String,
event: Value,
parent_tool_use_id: Option<String>,
},
RateLimit {
rate_limit_info: RateLimitInfo,
uuid: String,
session_id: String,
},
Unknown {
msg_type: String,
raw: Value,
},
}Expand description
Main message type enum
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
User
User message
Fields
§
message: UserMessageMessage content
Assistant
Assistant message
Fields
§
message: AssistantMessageMessage content
System
System message
Result
Result message indicating end of turn
Fields
StreamEvent
Stream event from the CLI
Fields
RateLimit
Rate limit notification
Fields
§
rate_limit_info: RateLimitInfoRate limit details
Unknown
Unknown message type (forward compatibility) Not deserialized by serde — constructed by message_parser
Implementations§
Source§impl Message
impl Message
Sourcepub fn as_task_started(&self) -> Option<TaskStartedMessage>
pub fn as_task_started(&self) -> Option<TaskStartedMessage>
Try to extract a TaskStartedMessage from a System message
Sourcepub fn as_task_progress(&self) -> Option<TaskProgressMessage>
pub fn as_task_progress(&self) -> Option<TaskProgressMessage>
Try to extract a TaskProgressMessage from a System message
Sourcepub fn as_task_notification(&self) -> Option<TaskNotificationMessage>
pub fn as_task_notification(&self) -> Option<TaskNotificationMessage>
Try to extract a TaskNotificationMessage from a System message
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
impl StructuralPartialEq for Message
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more