pub enum ToolResultContent {
Text(Text),
Image(Image),
Json {
value: Value,
},
}Expand description
Describes one typed item in a tool result.
Variants§
Text(Text)
Literal text. Providers must not reinterpret it as structured JSON.
Image(Image)
An image supplied explicitly by the tool.
Json
Structured JSON supplied explicitly by the tool runtime.
Implementations§
Source§impl ToolResultContent
impl ToolResultContent
Sourcepub fn deserialize_json<T>(&self) -> Result<T, Error>where
T: DeserializeOwned,
pub fn deserialize_json<T>(&self) -> Result<T, Error>where
T: DeserializeOwned,
Deserialize JSON content into a typed value.
Structured JSON is decoded directly. Literal text is parsed only because the caller explicitly requested JSON decoding, which supports transcripts recorded before structured tool output was preserved canonically. This helper never changes the content sent to a model or provider.
Source§impl ToolResultContent
impl ToolResultContent
Sourcepub fn image_base64(
data: impl Into<String>,
media_type: Option<ImageMediaType>,
detail: Option<ImageDetail>,
) -> Self
pub fn image_base64( data: impl Into<String>, media_type: Option<ImageMediaType>, detail: Option<ImageDetail>, ) -> Self
Creates tool-result image content from base64-encoded data.
Sourcepub fn image_raw(
data: impl Into<Vec<u8>>,
media_type: Option<ImageMediaType>,
detail: Option<ImageDetail>,
) -> Self
pub fn image_raw( data: impl Into<Vec<u8>>, media_type: Option<ImageMediaType>, detail: Option<ImageDetail>, ) -> Self
Creates tool-result image content from raw, unencoded bytes.
Sourcepub fn image_url(
data: impl Into<String>,
media_type: Option<ImageMediaType>,
detail: Option<ImageDetail>,
) -> Self
pub fn image_url( data: impl Into<String>, media_type: Option<ImageMediaType>, detail: Option<ImageDetail>, ) -> Self
Creates tool-result image content referencing a URL.
Trait Implementations§
Source§impl Clone for ToolResultContent
impl Clone for ToolResultContent
Source§impl Debug for ToolResultContent
impl Debug for ToolResultContent
Source§impl<'de> Deserialize<'de> for ToolResultContent
impl<'de> Deserialize<'de> for ToolResultContent
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<String> for ToolResultContent
impl From<String> for ToolResultContent
Source§impl From<ToolResultContent> for ToolOutput
impl From<ToolResultContent> for ToolOutput
Source§fn from(content: ToolResultContent) -> Self
fn from(content: ToolResultContent) -> Self
Converts to this type from the input type.
Source§impl PartialEq for ToolResultContent
impl PartialEq for ToolResultContent
Source§impl Serialize for ToolResultContent
impl Serialize for ToolResultContent
impl StructuralPartialEq for ToolResultContent
Auto Trait Implementations§
impl Freeze for ToolResultContent
impl RefUnwindSafe for ToolResultContent
impl Send for ToolResultContent
impl Sync for ToolResultContent
impl Unpin for ToolResultContent
impl UnsafeUnpin for ToolResultContent
impl UnwindSafe for ToolResultContent
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> ⓘ
Converts
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> ⓘ
Converts
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 moreSource§impl<T> IntoToolOutput for Twhere
T: Serialize + 'static,
impl<T> IntoToolOutput for Twhere
T: Serialize + 'static,
Source§fn into_tool_output(self) -> Result<ToolOutput, ToolExecutionError>
fn into_tool_output(self) -> Result<ToolOutput, ToolExecutionError>
Convert this value without routing structured data through a string.