pub struct ToolRegistry { /* private fields */ }Expand description
A thread-safe registry of tools.
Implementations§
Source§impl ToolRegistry
impl ToolRegistry
Sourcepub fn register<T: Tool + 'static>(&self, tool: T) -> Option<Arc<dyn Tool>>
pub fn register<T: Tool + 'static>(&self, tool: T) -> Option<Arc<dyn Tool>>
Registers a tool, returning any previous tool with the same name.
Sourcepub fn register_arc(&self, tool: Arc<dyn Tool>) -> Option<Arc<dyn Tool>>
pub fn register_arc(&self, tool: Arc<dyn Tool>) -> Option<Arc<dyn Tool>>
Registers an already-shared tool, returning any previous tool with the same name.
Sourcepub fn specs(&self) -> Vec<ToolSpec>
pub fn specs(&self) -> Vec<ToolSpec>
Generates ToolSpecs for all registered tools, sorted by name.
Sourcepub async fn execute(
&self,
ctx: &dyn ToolContext,
call: &ToolCall,
) -> ToolResult<ToolOutput>
pub async fn execute( &self, ctx: &dyn ToolContext, call: &ToolCall, ) -> ToolResult<ToolOutput>
Looks up and executes a tool call.
Trait Implementations§
Source§impl Clone for ToolRegistry
impl Clone for ToolRegistry
Source§impl Debug for ToolRegistry
impl Debug for ToolRegistry
Auto Trait Implementations§
impl !Freeze for ToolRegistry
impl RefUnwindSafe for ToolRegistry
impl Send for ToolRegistry
impl Sync for ToolRegistry
impl Unpin for ToolRegistry
impl UnsafeUnpin for ToolRegistry
impl UnwindSafe for ToolRegistry
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