pub struct ToolResult {
pub result: ToolResultPart,
pub duration: Option<Duration>,
pub metadata: BTreeMap<String, Value>,
}Expand description
The output produced by a successful tool invocation.
Returned from Tool::invoke and wrapped by ToolExecutionOutcome::Completed
after the executor finishes permission checks and execution.
Fields§
§result: ToolResultPartThe content payload sent back to the model.
duration: Option<Duration>Wall-clock time the tool took to run, if measured.
metadata: BTreeMap<String, Value>Arbitrary key-value pairs for framework extensions.
Implementations§
Source§impl ToolResult
impl ToolResult
Sourcepub fn new(result: ToolResultPart) -> ToolResult
pub fn new(result: ToolResultPart) -> ToolResult
Builds a tool result with no duration and empty metadata.
Sourcepub fn with_duration(self, duration: Duration) -> ToolResult
pub fn with_duration(self, duration: Duration) -> ToolResult
Sets the measured duration.
Sourcepub fn with_metadata(self, metadata: BTreeMap<String, Value>) -> ToolResult
pub fn with_metadata(self, metadata: BTreeMap<String, Value>) -> ToolResult
Replaces the result metadata.
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<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 PartialEq for ToolResult
impl PartialEq for ToolResult
Source§fn eq(&self, other: &ToolResult) -> bool
fn eq(&self, other: &ToolResult) -> bool
Tests for
self and other values to be equal, and is used by ==.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