pub struct ToolResultExtensions { /* private fields */ }Expand description
Type-erased metadata a tool attaches to its structured result.
The result-side counterpart of ToolCallExtensions. A tool builds these on
its ToolReturn (or directly on a
ToolExecutionResult) to carry
provider-specific or application-specific values — raw HTTP headers, a
provider response id, retry hints — alongside the model-visible output.
These are machine-visible only: they are surfaced to hooks (via
StepEvent::ToolResult), tracing, and
policies, but are never serialized into the tool result the model sees.
This is the same “not sent to the model” contract as Pydantic AI’s tool-return
metadata and the Vercel AI SDK’s toolMetadata.
Backed by the same internal TypeMap as ToolCallExtensions, so an empty set (the
common case) allocates nothing.
§Example
use rig_core::tool::ToolResultExtensions;
#[derive(Clone, Debug, PartialEq)]
struct HttpStatus(u16);
let mut extensions = ToolResultExtensions::new();
extensions.insert(HttpStatus(404));
assert_eq!(extensions.get::<HttpStatus>(), Some(&HttpStatus(404)));Implementations§
Source§impl ToolResultExtensions
impl ToolResultExtensions
Sourcepub fn insert<T: Clone + WasmCompatSend + WasmCompatSync + 'static>(
&mut self,
val: T,
) -> Option<T>
pub fn insert<T: Clone + WasmCompatSend + WasmCompatSync + 'static>( &mut self, val: T, ) -> Option<T>
Insert a typed value, returning the previous value of the same type if one was present.
Sourcepub fn get<T: WasmCompatSend + WasmCompatSync + 'static>(&self) -> Option<&T>
pub fn get<T: WasmCompatSend + WasmCompatSync + 'static>(&self) -> Option<&T>
Get a reference to a value by type. Returns None if not present.
Sourcepub fn require<T: WasmCompatSend + WasmCompatSync + 'static>(
&self,
) -> Result<&T, MissingExtension>
pub fn require<T: WasmCompatSend + WasmCompatSync + 'static>( &self, ) -> Result<&T, MissingExtension>
Get a reference to a value by type, returning a descriptive error naming
the missing type instead of a silent None.
Sourcepub fn get_mut<T: WasmCompatSend + WasmCompatSync + 'static>(
&mut self,
) -> Option<&mut T>
pub fn get_mut<T: WasmCompatSend + WasmCompatSync + 'static>( &mut self, ) -> Option<&mut T>
Get a mutable reference to a value by type. Returns None if not present.
Sourcepub fn remove<T: WasmCompatSend + WasmCompatSync + 'static>(
&mut self,
) -> Option<T>
pub fn remove<T: WasmCompatSend + WasmCompatSync + 'static>( &mut self, ) -> Option<T>
Remove a value by type, returning it if present.
Sourcepub fn contains<T: WasmCompatSend + WasmCompatSync + 'static>(&self) -> bool
pub fn contains<T: WasmCompatSend + WasmCompatSync + 'static>(&self) -> bool
Check if a value of the given type is present.
Trait Implementations§
Source§impl Clone for ToolResultExtensions
impl Clone for ToolResultExtensions
Source§fn clone(&self) -> ToolResultExtensions
fn clone(&self) -> ToolResultExtensions
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ToolResultExtensions
impl Debug for ToolResultExtensions
Source§impl Default for ToolResultExtensions
impl Default for ToolResultExtensions
Source§fn default() -> ToolResultExtensions
fn default() -> ToolResultExtensions
Auto Trait Implementations§
impl !RefUnwindSafe for ToolResultExtensions
impl !UnwindSafe for ToolResultExtensions
impl Freeze for ToolResultExtensions
impl Send for ToolResultExtensions
impl Sync for ToolResultExtensions
impl Unpin for ToolResultExtensions
impl UnsafeUnpin for ToolResultExtensions
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneDebuggableStorage for Twhere
T: DebuggableStorage + Clone,
impl<T> CloneDebuggableStorage for Twhere
T: DebuggableStorage + Clone,
fn clone_storage(&self) -> Box<dyn CloneDebuggableStorage>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> CloneableStorage for T
impl<T> CloneableStorage for T
fn clone_storage(&self) -> Box<dyn CloneableStorage>
impl<T> DebuggableStorage for T
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> 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>
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>
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 more