pub enum MessageContent {
Text(String),
Blocks(Vec<ContentBlock>),
}Expand description
Message content that can be either a plain string or an array of content blocks.
Claude Code uses different formats depending on the message type:
- Initial user prompts:
"content": "hello"(plain string) - Tool results/complex messages:
"content": [{"type": "text", "text": "..."}](array)
Variants§
Text(String)
Plain text content (used for simple user prompts)
Blocks(Vec<ContentBlock>)
Array of content blocks (used for tool results, assistant messages)
Implementations§
Source§impl MessageContent
impl MessageContent
Sourcepub fn text(&self) -> Option<&str>
pub fn text(&self) -> Option<&str>
Extract plain text from the content, if available.
For Text variant, returns the string directly.
For Blocks variant, finds the first text block and returns its content.
Sourcepub fn blocks(&self) -> Option<&[ContentBlock]>
pub fn blocks(&self) -> Option<&[ContentBlock]>
Get content blocks, if this is the Blocks variant.
Trait Implementations§
Source§impl Clone for MessageContent
impl Clone for MessageContent
Source§fn clone(&self) -> MessageContent
fn clone(&self) -> MessageContent
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 MessageContent
impl Debug for MessageContent
Source§impl PartialEq for MessageContent
impl PartialEq for MessageContent
impl StructuralPartialEq for MessageContent
Auto Trait Implementations§
impl Freeze for MessageContent
impl RefUnwindSafe for MessageContent
impl Send for MessageContent
impl Sync for MessageContent
impl Unpin 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