pub struct Message {
pub role: MessageRole,
pub content: Option<MessageContent>,
pub model: Option<String>,
pub id: Option<String>,
pub message_type: Option<String>,
pub stop_reason: Option<String>,
pub stop_sequence: Option<String>,
pub usage: Option<Usage>,
}Fields§
§role: MessageRole§content: Option<MessageContent>§model: Option<String>§id: Option<String>§message_type: Option<String>§stop_reason: Option<String>§stop_sequence: Option<String>§usage: Option<Usage>Implementations§
Source§impl Message
impl Message
Sourcepub fn text(&self) -> String
pub fn text(&self) -> String
Collapsed text content, joining all text parts with newlines.
Returns an empty string if content is None or contains no text parts.
Sourcepub fn thinking(&self) -> Option<Vec<&str>>
pub fn thinking(&self) -> Option<Vec<&str>>
Thinking blocks, if any.
Returns None when the message has no thinking content (not an empty vec).
Sourcepub fn tool_uses(&self) -> Vec<ToolUseRef<'_>>
pub fn tool_uses(&self) -> Vec<ToolUseRef<'_>>
Tool use entries, if any.
Sourcepub fn is_role(&self, role: MessageRole) -> bool
pub fn is_role(&self, role: MessageRole) -> bool
Whether this message has the given role.
Sourcepub fn is_assistant(&self) -> bool
pub fn is_assistant(&self) -> bool
Whether this is an assistant 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
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