pub enum ContentBlock {
Text(TextBlock),
Image(ImageBlock),
ToolUse(ToolUseBlock),
ServerToolUse(ServerToolUseBlock),
WebSearchToolResult(WebSearchToolResultBlock),
ToolResult(ToolResultBlock),
Document(DocumentBlock),
Thinking(ThinkingBlock),
RedactedThinking(RedactedThinkingBlock),
CodeExecutionResult(CodeExecutionResultBlock),
ProgrammaticToolUse(ProgrammaticToolUseBlock),
}anthropic-client only.Expand description
A block of content in a message.
This enum represents the different types of content blocks that can be included in a message’s content.
Variants§
Text(TextBlock)
A block of text content
Image(ImageBlock)
An image block
ToolUse(ToolUseBlock)
A block representing a tool use request
ServerToolUse(ServerToolUseBlock)
A block representing a server-side tool use request
WebSearchToolResult(WebSearchToolResultBlock)
A web search tool result block
ToolResult(ToolResultBlock)
A tool result block
Document(DocumentBlock)
A document block
Thinking(ThinkingBlock)
A block containing model thinking
RedactedThinking(RedactedThinkingBlock)
A block containing redacted thinking data
CodeExecutionResult(CodeExecutionResultBlock)
A code execution result block
ProgrammaticToolUse(ProgrammaticToolUseBlock)
A programmatic tool use block from code execution
Implementations§
Source§impl ContentBlock
impl ContentBlock
Sourcepub fn is_tool_use(&self) -> bool
pub fn is_tool_use(&self) -> bool
Returns true if this block is a tool use block
Sourcepub fn is_server_tool_use(&self) -> bool
pub fn is_server_tool_use(&self) -> bool
Returns true if this block is a server tool use block
Sourcepub fn is_web_search_tool_result(&self) -> bool
pub fn is_web_search_tool_result(&self) -> bool
Returns true if this block is a web search tool result block
Sourcepub fn is_tool_result(&self) -> bool
pub fn is_tool_result(&self) -> bool
Returns true if this block is a tool result block
Sourcepub fn is_document(&self) -> bool
pub fn is_document(&self) -> bool
Returns true if this block is a document block
Sourcepub fn is_thinking(&self) -> bool
pub fn is_thinking(&self) -> bool
Returns true if this block is a thinking block
Sourcepub fn is_redacted_thinking(&self) -> bool
pub fn is_redacted_thinking(&self) -> bool
Returns true if this block is a redacted thinking block
Sourcepub fn as_text(&self) -> Option<&TextBlock>
pub fn as_text(&self) -> Option<&TextBlock>
Returns a reference to the inner TextBlock if this is a Text variant, or None otherwise.
Sourcepub fn as_image(&self) -> Option<&ImageBlock>
pub fn as_image(&self) -> Option<&ImageBlock>
Returns a reference to the inner ImageBlock if this is an Image variant, or None otherwise.
Sourcepub fn as_tool_use(&self) -> Option<&ToolUseBlock>
pub fn as_tool_use(&self) -> Option<&ToolUseBlock>
Returns a reference to the inner ToolUseBlock if this is a ToolUse variant, or None otherwise.
Sourcepub fn as_server_tool_use(&self) -> Option<&ServerToolUseBlock>
pub fn as_server_tool_use(&self) -> Option<&ServerToolUseBlock>
Returns a reference to the inner ServerToolUseBlock if this is a ServerToolUse variant, or None otherwise.
Sourcepub fn as_web_search_tool_result(&self) -> Option<&WebSearchToolResultBlock>
pub fn as_web_search_tool_result(&self) -> Option<&WebSearchToolResultBlock>
Returns a reference to the inner WebSearchToolResultBlock if this is a WebSearchToolResult variant, or None otherwise.
Sourcepub fn as_tool_result(&self) -> Option<&ToolResultBlock>
pub fn as_tool_result(&self) -> Option<&ToolResultBlock>
Returns a reference to the inner ToolResultBlock if this is a ToolResult variant, or None otherwise.
Sourcepub fn as_document(&self) -> Option<&DocumentBlock>
pub fn as_document(&self) -> Option<&DocumentBlock>
Returns a reference to the inner DocumentBlock if this is a Document variant, or None otherwise.
Sourcepub fn as_thinking(&self) -> Option<&ThinkingBlock>
pub fn as_thinking(&self) -> Option<&ThinkingBlock>
Returns a reference to the inner ThinkingBlock if this is a Thinking variant, or None otherwise.
Sourcepub fn as_redacted_thinking(&self) -> Option<&RedactedThinkingBlock>
pub fn as_redacted_thinking(&self) -> Option<&RedactedThinkingBlock>
Returns a reference to the inner RedactedThinkingBlock if this is a RedactedThinking variant, or None otherwise.
Sourcepub fn is_code_execution_result(&self) -> bool
pub fn is_code_execution_result(&self) -> bool
Returns true if this block is a code execution result block
Sourcepub fn as_code_execution_result(&self) -> Option<&CodeExecutionResultBlock>
pub fn as_code_execution_result(&self) -> Option<&CodeExecutionResultBlock>
Returns a reference to the inner CodeExecutionResultBlock if this is a CodeExecutionResult variant, or None otherwise.
Sourcepub fn is_programmatic_tool_use(&self) -> bool
pub fn is_programmatic_tool_use(&self) -> bool
Returns true if this block is a programmatic tool use block
Sourcepub fn as_programmatic_tool_use(&self) -> Option<&ProgrammaticToolUseBlock>
pub fn as_programmatic_tool_use(&self) -> Option<&ProgrammaticToolUseBlock>
Returns a reference to the inner ProgrammaticToolUseBlock if this is a ProgrammaticToolUse variant, or None otherwise.
Trait Implementations§
Source§impl Clone for ContentBlock
impl Clone for ContentBlock
Source§fn clone(&self) -> ContentBlock
fn clone(&self) -> ContentBlock
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ContentBlock
impl Debug for ContentBlock
Source§impl<'de> Deserialize<'de> for ContentBlock
impl<'de> Deserialize<'de> for ContentBlock
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<ContentBlock, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<ContentBlock, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl From<CodeExecutionResultBlock> for ContentBlock
impl From<CodeExecutionResultBlock> for ContentBlock
Source§fn from(block: CodeExecutionResultBlock) -> ContentBlock
fn from(block: CodeExecutionResultBlock) -> ContentBlock
Source§impl From<DocumentBlock> for ContentBlock
impl From<DocumentBlock> for ContentBlock
Source§fn from(block: DocumentBlock) -> ContentBlock
fn from(block: DocumentBlock) -> ContentBlock
Source§impl From<ImageBlock> for ContentBlock
impl From<ImageBlock> for ContentBlock
Source§fn from(block: ImageBlock) -> ContentBlock
fn from(block: ImageBlock) -> ContentBlock
Source§impl From<ProgrammaticToolUseBlock> for ContentBlock
impl From<ProgrammaticToolUseBlock> for ContentBlock
Source§fn from(block: ProgrammaticToolUseBlock) -> ContentBlock
fn from(block: ProgrammaticToolUseBlock) -> ContentBlock
Source§impl From<RedactedThinkingBlock> for ContentBlock
impl From<RedactedThinkingBlock> for ContentBlock
Source§fn from(block: RedactedThinkingBlock) -> ContentBlock
fn from(block: RedactedThinkingBlock) -> ContentBlock
Source§impl From<ServerToolUseBlock> for ContentBlock
impl From<ServerToolUseBlock> for ContentBlock
Source§fn from(block: ServerToolUseBlock) -> ContentBlock
fn from(block: ServerToolUseBlock) -> ContentBlock
Source§impl From<TextBlock> for ContentBlock
Helper methods to create ContentBlock variants
impl From<TextBlock> for ContentBlock
Helper methods to create ContentBlock variants
Source§fn from(block: TextBlock) -> ContentBlock
fn from(block: TextBlock) -> ContentBlock
Source§impl From<ThinkingBlock> for ContentBlock
impl From<ThinkingBlock> for ContentBlock
Source§fn from(block: ThinkingBlock) -> ContentBlock
fn from(block: ThinkingBlock) -> ContentBlock
Source§impl From<ToolResultBlock> for ContentBlock
impl From<ToolResultBlock> for ContentBlock
Source§fn from(block: ToolResultBlock) -> ContentBlock
fn from(block: ToolResultBlock) -> ContentBlock
Source§impl From<ToolUseBlock> for ContentBlock
impl From<ToolUseBlock> for ContentBlock
Source§fn from(block: ToolUseBlock) -> ContentBlock
fn from(block: ToolUseBlock) -> ContentBlock
Source§impl From<WebSearchToolResultBlock> for ContentBlock
impl From<WebSearchToolResultBlock> for ContentBlock
Source§fn from(block: WebSearchToolResultBlock) -> ContentBlock
fn from(block: WebSearchToolResultBlock) -> ContentBlock
Source§impl PartialEq for ContentBlock
impl PartialEq for ContentBlock
Source§fn eq(&self, other: &ContentBlock) -> bool
fn eq(&self, other: &ContentBlock) -> bool
self and other values to be equal, and is used by ==.