pub enum ContentBlock {
Text(TextContent),
Image(ImageContent),
Audio(AudioContent),
ResourceLink(ResourceLink),
EmbeddedResource(EmbeddedResource),
}Expand description
A content block that can be used in prompts and tool results.
Variants§
Text(TextContent)
Text content.
Image(ImageContent)
Image content (base64-encoded).
Audio(AudioContent)
Audio content (base64-encoded).
ResourceLink(ResourceLink)
A resource link.
EmbeddedResource(EmbeddedResource)
An embedded resource.
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<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl From<ContentBlock> for RichContentPart
Available on crate feature mcp only.
impl From<ContentBlock> for RichContentPart
mcp only.Source§fn from(block: ContentBlock) -> Self
fn from(block: ContentBlock) -> Self
Source§impl From<File> for ContentBlock
Direct conversion from a typed File to a ContentBlock.
Multi-field collapse:
file_data > file_url > file_id by precedence. Lower-priority
fields are dropped; filename rides through via _meta.
impl From<File> for ContentBlock
Direct conversion from a typed File to a ContentBlock.
Multi-field collapse:
file_data > file_url > file_id by precedence. Lower-priority
fields are dropped; filename rides through via _meta.
Source§impl From<ImageUrl> for ContentBlock
Direct conversion from a typed ImageUrl to a ContentBlock.
Same body as the RichContentPart::ImageUrl arm of
[From<RichContentPart> for ContentBlock] — kept independent so
per-leaf CommandResponse::into_mcp impls (whose Response is
already an ImageUrl) can call image_url.into() without first
wrapping in RichContentPart.
impl From<ImageUrl> for ContentBlock
Direct conversion from a typed ImageUrl to a ContentBlock.
Same body as the RichContentPart::ImageUrl arm of
[From<RichContentPart> for ContentBlock] — kept independent so
per-leaf CommandResponse::into_mcp impls (whose Response is
already an ImageUrl) can call image_url.into() without first
wrapping in RichContentPart.
Source§impl From<InputAudio> for ContentBlock
Direct conversion from a typed InputAudio to a ContentBlock.
Same body as the RichContentPart::InputAudio arm of
[From<RichContentPart> for ContentBlock].
impl From<InputAudio> for ContentBlock
Direct conversion from a typed InputAudio to a ContentBlock.
Same body as the RichContentPart::InputAudio arm of
[From<RichContentPart> for ContentBlock].
Source§fn from(input_audio: InputAudio) -> Self
fn from(input_audio: InputAudio) -> Self
Source§impl From<RichContentPart> for ContentBlock
Convert a single RichContentPart into a ContentBlock.
impl From<RichContentPart> for ContentBlock
Convert a single RichContentPart into a ContentBlock.
Forward path produces only Text, Image, and Audio carriers
— never EmbeddedResource or ResourceLink. See the
module-level docs for the round-trip property and the _meta
marker catalogue.
Upstream-specific converters (claude_agent_sdk, codex_sdk)
use stricter TryFrom impls that reject unsupported parts. This
From is the generic, round-trip-preserving path used by
agent/completions/notify and the MCP tool-response formatter.
Source§fn from(part: RichContentPart) -> Self
fn from(part: RichContentPart) -> Self
Source§impl From<VideoUrl> for ContentBlock
Direct conversion from a typed VideoUrl to a ContentBlock.
Shared forward path for both RichContentPart::InputVideo and
RichContentPart::VideoUrl: data-URL videos round-trip via the
default reverse heuristic (parse_data_url → video/* mime →
InputVideo), so no marker. Remote URLs get
META_KIND = "input_video_remote" so the reverse rebuilds an
InputVideo. See the third round-trip exception in the
module-level docs.
impl From<VideoUrl> for ContentBlock
Direct conversion from a typed VideoUrl to a ContentBlock.
Shared forward path for both RichContentPart::InputVideo and
RichContentPart::VideoUrl: data-URL videos round-trip via the
default reverse heuristic (parse_data_url → video/* mime →
InputVideo), so no marker. Remote URLs get
META_KIND = "input_video_remote" so the reverse rebuilds an
InputVideo. See the third round-trip exception in the
module-level docs.
Source§impl JsonSchema for ContentBlock
impl JsonSchema for ContentBlock
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreAuto 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
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> 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 more