pub enum MessagePart {
Text {
text: String,
},
ToolOutput {
tool_name: String,
body: String,
compacted_at: Option<i64>,
},
Recall {
text: String,
},
CodeContext {
text: String,
},
Summary {
text: String,
},
CrossSession {
text: String,
},
ToolUse {
id: String,
name: String,
input: Value,
},
ToolResult {
tool_use_id: String,
content: String,
is_error: bool,
},
Image(Box<ImageData>),
ThinkingBlock {
thinking: String,
signature: String,
},
RedactedThinkingBlock {
data: String,
},
Compaction {
summary: String,
},
}Variants§
Text
ToolOutput
Recall
CodeContext
Summary
CrossSession
ToolUse
ToolResult
Image(Box<ImageData>)
ThinkingBlock
Claude thinking block — must be preserved verbatim in multi-turn requests.
RedactedThinkingBlock
Claude redacted thinking block — preserved as-is in multi-turn requests.
Compaction
Claude server-side compaction block — must be preserved verbatim in multi-turn requests so the API can correctly prune prior history on the next turn.
Implementations§
Source§impl MessagePart
impl MessagePart
Sourcepub fn as_plain_text(&self) -> Option<&str>
pub fn as_plain_text(&self) -> Option<&str>
Return the plain text content if this part is a text-like variant (Text, Recall,
CodeContext, Summary, CrossSession), None otherwise.
Trait Implementations§
Source§impl Clone for MessagePart
impl Clone for MessagePart
Source§fn clone(&self) -> MessagePart
fn clone(&self) -> MessagePart
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MessagePart
impl Debug for MessagePart
Source§impl<'de> Deserialize<'de> for MessagePart
impl<'de> Deserialize<'de> for MessagePart
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 MessagePart
impl RefUnwindSafe for MessagePart
impl Send for MessagePart
impl Sync for MessagePart
impl Unpin for MessagePart
impl UnsafeUnpin for MessagePart
impl UnwindSafe for MessagePart
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