pub enum ContentBlock {
Text(TextBlock),
Image(ImageBlock),
ToolUse(ToolUseBlock),
ServerToolUse(ServerToolUseBlock),
WebSearchToolResult(WebSearchToolResultBlock),
WebFetchToolResult(WebFetchToolResultBlock),
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
WebFetchToolResult(WebFetchToolResultBlock)
A web fetch 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_web_fetch_tool_result(&self) -> bool
pub fn is_web_fetch_tool_result(&self) -> bool
Returns true if this block is a web fetch 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_web_fetch_tool_result(&self) -> Option<&WebFetchToolResultBlock>
pub fn as_web_fetch_tool_result(&self) -> Option<&WebFetchToolResultBlock>
Returns a reference to the inner WebFetchToolResultBlock if this is a WebFetchToolResult 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<WebFetchToolResultBlock> for ContentBlock
impl From<WebFetchToolResultBlock> for ContentBlock
Source§fn from(block: WebFetchToolResultBlock) -> ContentBlock
fn from(block: WebFetchToolResultBlock) -> 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§impl Serialize for ContentBlock
impl Serialize for ContentBlock
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for ContentBlock
Auto Trait Implementations§
impl Freeze for ContentBlock
impl RefUnwindSafe for ContentBlock
impl Send for ContentBlock
impl Sync for ContentBlock
impl Unpin for ContentBlock
impl UnsafeUnpin for ContentBlock
impl UnwindSafe for ContentBlock
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreimpl<T> MaybeSend for Twhere
T: Send,
Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.