pub enum ContentBlock {
Text(TextContent),
Thinking(ThinkingContent),
Image(ImageContent),
ToolCall(ToolCall),
Unknown(Value),
}Expand description
Message types for constructing conversations. Content block union (untagged for flexibility).
Represents a single piece of content inside a message – text, thinking, an image, a tool call, or an unrecognized block kept as raw JSON.
Variants§
Text(TextContent)
Plain text content.
Thinking(ThinkingContent)
Extended thinking / chain-of-thought output.
Image(ImageContent)
Base64-encoded image.
ToolCall(ToolCall)
Tool invocation requested by the model.
Unknown(Value)
Unrecognised block preserved as raw JSON.
Implementations§
Source§impl ContentBlock
impl ContentBlock
Sourcepub fn as_tool_call(&self) -> Option<&ToolCall>
pub fn as_tool_call(&self) -> Option<&ToolCall>
Returns a reference to the ToolCall if this is a ToolCall block.
Sourcepub fn as_thinking(&self) -> Option<&ThinkingContent>
pub fn as_thinking(&self) -> Option<&ThinkingContent>
Returns a reference to the ThinkingContent if this is a Thinking block.
Trait Implementations§
Source§impl Clone for ContentBlock
impl Clone for ContentBlock
Source§fn clone(&self) -> ContentBlock
fn clone(&self) -> ContentBlock
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 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<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
Source§impl From<ContentBlock> for MessageContent
impl From<ContentBlock> for MessageContent
Source§fn from(block: ContentBlock) -> Self
fn from(block: ContentBlock) -> Self
Converts to this type from the input type.
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
Mutably borrows from an owned value. Read more