pub struct ToolResult {
pub output: Value,
pub success: bool,
pub metadata: HashMap<String, Value>,
}Expand description
Structured result from tool execution.
Wraps the tool’s output value with optional metadata (result count, source,
confidence, execution details, etc.). Backward-compatible: Value auto-converts
to ToolResult::ok(value).
§Example
use pe_tools::tool::ToolResult;
use serde_json::json;
let result = ToolResult::ok(json!({"answer": 42}))
.with_metadata("source", json!("database"))
.with_metadata("result_count", json!(1));
assert!(result.success);
assert_eq!(result.metadata["source"], "database");Fields§
§output: ValueThe tool’s output value.
success: boolWhether the tool succeeded.
metadata: HashMap<String, Value>Tool-specific metadata (result count, source, confidence, etc.).
Implementations§
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<'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 From<Value> for ToolResult
Backward compatibility: raw Value auto-converts to successful ToolResult.
impl From<Value> for ToolResult
Backward compatibility: raw Value auto-converts to successful 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