pub enum ContentBlock {
Text(TextBlock),
ToolUse(ToolUseBlock),
ToolResult(ToolResultBlock),
Image(ImageBlock),
Attachment(AttachmentBlock),
Thinking(ThinkingBlock),
Unknown,
}Expand description
Content block discriminator
All possible content block types found in message content arrays.
Uses serde’s tagged enum to automatically parse based on type field.
§Links
- User messages contain:
Text,ToolResult,Image - Assistant messages contain:
Text,ToolUse,Thinking(when extended thinking enabled) - Progress normalized messages contain: all types including
Attachment
§Frequency (per large session)
ToolUse: ~30k occurrencesToolResult: ~30k occurrencesText: ~19k occurrencesThinking: Variable (only when extended thinking mode enabled)Image: ~5 occurrences
Variants§
Text(TextBlock)
Text content block
Found in: user messages, assistant messages
Contains plain text or markdown from user input or assistant responses.
ToolUse(ToolUseBlock)
Tool use invocation
Found in: assistant messages
Represents Claude invoking a tool (Read, Write, Edit, Bash, etc.)
ToolResult(ToolResultBlock)
Tool execution result
Found in: user messages (as tool result feedback)
Contains the output from a tool execution, sent back to Claude.
Image(ImageBlock)
Image attachment
Found in: user messages
Base64-encoded image data sent by user.
Attachment(AttachmentBlock)
Attachment (files, hooks, reminders)
Found in: progress normalized messages
See attachment module for detailed attachment types.
Thinking(ThinkingBlock)
Thinking block (extended thinking mode)
Found in: assistant messages (only when user enables extended thinking)
Contains Claude’s reasoning process with signature verification. This is OPTIONAL - only present when extended thinking mode is enabled.
Unknown
Unknown content block type (forward compatibility)
Implementations§
Source§impl ContentBlock
impl ContentBlock
Sourcepub fn as_tool_use(&self) -> Option<(&str, &str, &JsonValue)>
pub fn as_tool_use(&self) -> Option<(&str, &str, &JsonValue)>
Extract tool use if this is a tool use block
Sourcepub fn as_thinking(&self) -> Option<&str>
pub fn as_thinking(&self) -> Option<&str>
Extract thinking if this is a thinking block
Sourcepub fn is_tool_result(&self) -> bool
pub fn is_tool_result(&self) -> bool
Check if this is a tool result
Sourcepub fn is_attachment(&self) -> bool
pub fn is_attachment(&self) -> bool
Check if this is an attachment
Sourcepub fn is_thinking(&self) -> bool
pub fn is_thinking(&self) -> bool
Check if this is a thinking block