pub struct ToolResult {
pub content: Vec<Content>,
pub is_error: Option<bool>,
pub structured_content: Option<Value>,
pub meta: Option<HashMap<String, Value>>,
}Expand description
Result from calling a tool.
Fields§
§content: Vec<Content>Content blocks in the result
is_error: Option<bool>Whether this result represents an error
structured_content: Option<Value>Structured content conforming to the tool’s output schema
meta: Option<HashMap<String, Value>>Extension metadata
Implementations§
Source§impl ToolResult
impl ToolResult
Sourcepub fn text(text: impl Into<String>) -> ToolResult
pub fn text(text: impl Into<String>) -> ToolResult
Create a text result.
Sourcepub fn error(text: impl Into<String>) -> ToolResult
pub fn error(text: impl Into<String>) -> ToolResult
Create an error result.
Sourcepub fn json<T>(value: &T) -> Result<ToolResult, Error>where
T: Serialize,
pub fn json<T>(value: &T) -> Result<ToolResult, Error>where
T: Serialize,
Create a JSON result with structured content.
Sourcepub fn empty() -> ToolResult
pub fn empty() -> ToolResult
Create an empty result (no content).
Sourcepub fn with_structured<T>(self, value: &T) -> ToolResultwhere
T: Serialize,
pub fn with_structured<T>(self, value: &T) -> ToolResultwhere
T: Serialize,
Add structured content to the result.
Sourcepub fn with_content(self, content: Content) -> ToolResult
pub fn with_content(self, content: Content) -> ToolResult
Add additional content to the result.
Sourcepub fn with_image(
self,
data: impl Into<String>,
mime_type: impl Into<String>,
) -> ToolResult
pub fn with_image( self, data: impl Into<String>, mime_type: impl Into<String>, ) -> ToolResult
Add image content to the result.
Sourcepub fn first_text(&self) -> Option<&str>
pub fn first_text(&self) -> Option<&str>
Get the first text content if present.
Trait Implementations§
Source§impl Clone for ToolResult
impl Clone for ToolResult
Source§fn clone(&self) -> ToolResult
fn clone(&self) -> ToolResult
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ToolResult
impl Debug for ToolResult
Source§impl Default for ToolResult
impl Default for ToolResult
Source§fn default() -> ToolResult
fn default() -> ToolResult
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for ToolResult
impl<'de> Deserialize<'de> for ToolResult
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<ToolResult, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<ToolResult, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl IntoToolResult for ToolResult
impl IntoToolResult for ToolResult
Source§fn into_tool_result(self) -> ToolResult
fn into_tool_result(self) -> ToolResult
Convert this value into a
ToolResult.Source§impl PartialEq for ToolResult
impl PartialEq for ToolResult
Source§impl Serialize for ToolResult
impl Serialize for ToolResult
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl StructuralPartialEq for ToolResult
Auto Trait Implementations§
impl Freeze for ToolResult
impl RefUnwindSafe for ToolResult
impl Send for ToolResult
impl Sync for ToolResult
impl Unpin for ToolResult
impl UnsafeUnpin for ToolResult
impl UnwindSafe for ToolResult
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