pub struct ToolRegistry { /* private fields */ }Expand description
A collection of registered tools.
Implements ToolExecutor so the executor can call tools by name
without knowing anything about their implementation.
Tools are registered once at startup and never mutated during execution.
If the tool name is not in the registry, call() returns NotFound.
Implementations§
Source§impl ToolRegistry
impl ToolRegistry
Sourcepub fn register(&mut self, tool: Box<dyn Tool>)
pub fn register(&mut self, tool: Box<dyn Tool>)
Register a tool.
If a tool with the same name is already registered, it is replaced.
The registry takes ownership of the tool via Box<dyn Tool>.
Sourcepub fn registered_names(&self) -> Vec<&str>
pub fn registered_names(&self) -> Vec<&str>
Return the names of all registered tools.
Useful for debugging and nanny init suggestions.
Trait Implementations§
Source§impl Default for ToolRegistry
impl Default for ToolRegistry
Source§impl ToolExecutor for ToolRegistry
impl ToolExecutor for ToolRegistry
Source§fn call(&self, name: &str, args: &ToolArgs) -> Result<ToolOutput, ToolCallError>
fn call(&self, name: &str, args: &ToolArgs) -> Result<ToolOutput, ToolCallError>
Call a registered tool by name.
Returns NotFound if no tool with that name is registered.
Returns Execution if the tool was found but failed.
Auto Trait Implementations§
impl !RefUnwindSafe for ToolRegistry
impl !UnwindSafe for ToolRegistry
impl Freeze for ToolRegistry
impl Send for ToolRegistry
impl Sync for ToolRegistry
impl Unpin for ToolRegistry
impl UnsafeUnpin 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