#[non_exhaustive]pub enum Content {
Text(String),
ToolUse(ToolCall),
ToolResult(ToolResult),
Image(ImageRef),
}Expand description
A single content block within a Message.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Text(String)
Plain text.
ToolUse(ToolCall)
A tool invocation emitted by the model.
ToolResult(ToolResult)
The result of a prior Content::ToolUse, fed back to the model.
Image(ImageRef)
A reference to an image (HTTP URL or data: URI).
Implementations§
Source§impl Content
impl Content
Sourcepub fn text(s: impl Into<String>) -> Self
pub fn text(s: impl Into<String>) -> Self
Wraps s in a Content::Text variant.
Sourcepub fn tool_use(
id: impl Into<String>,
name: impl Into<String>,
args_json: impl Into<String>,
) -> Self
pub fn tool_use( id: impl Into<String>, name: impl Into<String>, args_json: impl Into<String>, ) -> Self
Constructs a Content::ToolUse block.
Sourcepub fn tool_use_signed(
id: impl Into<String>,
name: impl Into<String>,
args_json: impl Into<String>,
signature: Option<String>,
) -> Self
pub fn tool_use_signed( id: impl Into<String>, name: impl Into<String>, args_json: impl Into<String>, signature: Option<String>, ) -> Self
Constructs a Content::ToolUse block carrying an opaque
provider-specific signature (e.g. a thinking model’s thought
signature, which some providers require echoed back on the next
request that includes this call).
Sourcepub fn tool_result(
tool_call_id: impl Into<String>,
result_json: impl Into<String>,
is_error: bool,
) -> Self
pub fn tool_result( tool_call_id: impl Into<String>, result_json: impl Into<String>, is_error: bool, ) -> Self
Constructs a Content::ToolResult block.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Content
impl<'de> Deserialize<'de> for Content
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
Auto Trait Implementations§
impl Freeze for Content
impl RefUnwindSafe for Content
impl Send for Content
impl Sync for Content
impl Unpin for Content
impl UnsafeUnpin for Content
impl UnwindSafe for Content
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