pub struct MessageContent {
pub role: String,
pub content: Vec<ContentBlock>,
}Expand description
Message content wrapper
Contains role and content blocks for both user and assistant messages.
§Example
{
"role": "user",
"content": [
{"type": "text", "text": "Hello"},
{"type": "tool_result", "tool_use_id": "...", "content": "..."}
]
}§Wire format drift
Real Claude Code transcripts (v2.1.2xx) put a bare JSON string in
content for plain single-turn human prompts, not the documented array of
content blocks — the array form is only used once the turn carries
structured pieces (tool results, images, thinking). Both shapes are
accepted: a bare string normalizes to a single ContentBlock::Text.
Fields§
§role: StringRole: “user” or “assistant”
content: Vec<ContentBlock>Content blocks (text, tool use, tool results, etc.)
Accepts either the documented array-of-blocks shape or a bare string (the common shape for plain-text human prompts on disk).
Trait Implementations§
Source§impl Clone for MessageContent
impl Clone for MessageContent
Source§impl Debug for MessageContent
impl Debug for MessageContent
Source§impl<'de> Deserialize<'de> for MessageContent
impl<'de> Deserialize<'de> for MessageContent
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 MessageContent
impl RefUnwindSafe for MessageContent
impl Send for MessageContent
impl Sync for MessageContent
impl Unpin for MessageContent
impl UnsafeUnpin for MessageContent
impl UnwindSafe for MessageContent
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