Skip to main content

ContentBlock

Enum ContentBlock 

Source
pub enum ContentBlock {
Show 13 variants Text { text: String, cache_control: Option<CacheControl>, }, ImageUrl { image_url: ImageUrlContent, }, Thinking { thinking: String, signature: Option<String>, state: Option<OpaqueReasoningState>, redacted_data: Option<String>, }, ToolUse { id: String, name: String, input: Value, execution_id: Option<String>, caller: Option<ToolCaller>, thought_signature: Option<String>, }, ToolResult { tool_use_id: String, content: String, execution_id: Option<String>, is_error: Option<bool>, content_blocks: Option<Vec<Value>>, }, ServerToolUse { id: String, name: String, input: Value, kind: Option<String>, caller: Option<ToolCaller>, }, ToolSearchToolResult { tool_use_id: String, content: Value, }, CodeExecutionToolResult { tool_use_id: String, content: Value, }, WebSearchToolResult { tool_use_id: String, content: Value, kind: Option<String>, }, WebFetchToolResult { tool_use_id: String, content: Value, kind: Option<String>, signature: Option<String>, }, WebSearchCall { id: String, status: String, kind: Option<String>, action: Option<Value>, sources: Option<Value>, page: Option<Value>, signature: Option<String>, error: Option<Value>, }, ServerToolCalls { steps: Vec<Value>, }, File { file_id: String, },
}
Expand description

A single content block inside a message.

Variants§

§

Text

Fields

§text: String
§cache_control: Option<CacheControl>
§

ImageUrl

Fields

§

Thinking

Fields

§thinking: String
§signature: Option<String>

Anthropic signed-thinking signature (#3014). Only populated on the native Messages dialect and serde-skipped when absent so OpenAI dialects are unaffected. Anthropic rejects tool loops that drop or modify signed thinking blocks, so replay this verbatim.

§state: Option<OpaqueReasoningState>

Opaque Responses-style continuity. Never synthesize this from the readable thinking text or carry it across a route/model switch.

§redacted_data: Option<String>

Anthropic redacted_thinking payload (data): the encrypted replacement for a whole thinking block that the provider withheld for safety reasons. It must be replayed byte-exact — the API decrypts it to restore the turn’s reasoning — and is mutually exclusive with readable thinking text and with signature. Stored on the same variant (instead of a sibling one) so existing sessions and matches keep compiling; the serde field is absent for every non-redacted block.

§

ToolUse

Fields

§name: String
§input: Value
§execution_id: Option<String>

Host-owned execution correlation, distinct from the provider’s id. Persisted with history; provider adapters project only wire fields. Missing identifies legacy/provider-only history, never a new grant.

§thought_signature: Option<String>

Google thought signature captured from the OpenAI-compat route’s extra_content.google.thought_signature on the tool call. Google requires replaying it with the tool result for thinking models; skipped on the wire and in storage for every other provider.

§

ToolResult

Fields

§tool_use_id: String
§content: String
§execution_id: Option<String>

The exact host execution that produced this result, when recorded.

§is_error: Option<bool>
§content_blocks: Option<Vec<Value>>
§

ServerToolUse

Fields

§name: String
§input: Value
§

ToolSearchToolResult

Fields

§tool_use_id: String
§content: Value
§

CodeExecutionToolResult

Fields

§tool_use_id: String
§content: Value
§

WebSearchToolResult

Fields

§tool_use_id: String
§content: Value
§

WebFetchToolResult

Fields

§tool_use_id: String
§content: Value
§signature: Option<String>
§

WebSearchCall

Fields

§status: String
§action: Option<Value>
§sources: Option<Value>
§signature: Option<String>
§error: Option<Value>
§

ServerToolCalls

Fields

§steps: Vec<Value>
§

File

Fields

§file_id: String

Implementations§

Source§

impl ContentBlock

Source

pub fn tool_call_key(&self) -> Option<ToolCallKey<'_>>

Pairing identity in persisted host history. An explicit execution id never falls back to provider correlation, even if malformed or mismatched. Wire adapters must continue using the original id/tool_use_id instead.

Source

pub fn thinking(thinking: impl Into<String>) -> Self

Build readable reasoning with no provider-owned continuity state.

Trait Implementations§

Source§

impl Clone for ContentBlock

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ContentBlock

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for ContentBlock

Source§

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 PartialEq for ContentBlock

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for ContentBlock

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for ContentBlock

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.