pub struct ToolResult {
pub tool_use_id: String,
pub content: ToolResultContent,
pub is_error: Option<bool>,
}
Expand description
Result of a tool execution.
After executing a tool, return the result using this structure so Claude can incorporate it into its response.
Fields§
§tool_use_id: String
The ID of the tool use request this result corresponds to.
content: ToolResultContent
The result content from the tool execution.
is_error: Option<bool>
Whether the tool execution was successful.
Implementations§
Source§impl ToolResult
impl ToolResult
Sourcepub fn success(
tool_use_id: impl Into<String>,
content: impl Into<String>,
) -> Self
pub fn success( tool_use_id: impl Into<String>, content: impl Into<String>, ) -> Self
Create a successful tool result with text content.
Sourcepub fn success_json(tool_use_id: impl Into<String>, content: Value) -> Self
pub fn success_json(tool_use_id: impl Into<String>, content: Value) -> Self
Create a successful tool result with JSON content.
Sourcepub fn error(
tool_use_id: impl Into<String>,
error_message: impl Into<String>,
) -> Self
pub fn error( tool_use_id: impl Into<String>, error_message: impl Into<String>, ) -> Self
Create an error tool result.
Sourcepub fn with_blocks(
tool_use_id: impl Into<String>,
blocks: Vec<ToolResultBlock>,
) -> Self
pub fn with_blocks( tool_use_id: impl Into<String>, blocks: Vec<ToolResultBlock>, ) -> Self
Create a tool result with multiple content blocks.
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 · 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<'de> Deserialize<'de> for ToolResult
impl<'de> Deserialize<'de> for ToolResult
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 PartialEq for ToolResult
impl PartialEq for ToolResult
Source§impl Serialize for ToolResult
impl Serialize for ToolResult
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 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