pub enum ContentBlock {
Text {
text: String,
cache_control: Option<Value>,
},
Image {
source: ImageSource,
},
Document {
source: ImageSource,
title: Option<String>,
},
ToolUse {
id: String,
name: String,
input: Value,
},
ToolResult {
tool_use_id: String,
content: ToolResultContent,
is_error: bool,
},
Thinking {
thinking: String,
signature: Option<String>,
provider: Option<String>,
},
RedactedThinking {
data: String,
provider: Option<String>,
},
CacheEdits {
cache_edits: Vec<CacheEdit>,
},
}Expand description
内容块。type 字段做 enum tag。
字段名 / 取值与 Anthropic API 一致;外部 JSON 直传可读。
Variants§
Text
Image
Fields
§
source: ImageSourceDocument
ToolUse
ToolResult
Fields
§
content: ToolResultContent可以是 string 或 array of ContentBlock;用 ToolResultContent 区分
Thinking
Fields
RedactedThinking
CacheEdits
Anthropic cache_edits content block: requests server-side deletion of
cached tool result content by tool_use_id. Only meaningful in the request;
never returned by the API. Requires the context-management-2025-06-27
beta header.
Trait Implementations§
Source§impl Clone for ContentBlock
impl Clone for ContentBlock
Source§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 JsonSchema for ContentBlock
impl JsonSchema for ContentBlock
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Returns a string that uniquely identifies the schema produced by this type. Read more
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
Whether JSON Schemas generated for this type should be included directly in parent schemas,
rather than being re-used where possible using the
$ref keyword. Read moreSource§impl PartialEq for ContentBlock
impl PartialEq for ContentBlock
Source§impl Serialize for ContentBlock
impl Serialize for ContentBlock
impl StructuralPartialEq for ContentBlock
Auto Trait Implementations§
impl Forget for ContentBlock
impl Freeze for ContentBlock
impl Move 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