pub struct ToolRegistry { /* private fields */ }Expand description
Registry that stores tools by name and provides lookup + schema listing.
§Example
ⓘ
let mut registry = ToolRegistry::new();
registry.register(my_search_tool)?;
registry.register(my_calculator_tool)?;
// Get schemas for LLM prompt
let schemas = registry.schemas();
// Look up tool for execution
let tool = registry.get("search").unwrap();
let result = tool.execute(input).await?;Implementations§
Source§impl ToolRegistry
impl ToolRegistry
Sourcepub fn register(
&mut self,
tool: impl Tool + 'static,
) -> Result<&mut Self, PeError>
pub fn register( &mut self, tool: impl Tool + 'static, ) -> Result<&mut Self, PeError>
Register a tool with typed duplicate-name handling.
Sourcepub fn register_arc(
&mut self,
tool: Arc<dyn Tool>,
) -> Result<&mut Self, PeError>
pub fn register_arc( &mut self, tool: Arc<dyn Tool>, ) -> Result<&mut Self, PeError>
Register a pre-wrapped Arc<dyn Tool> with typed duplicate-name handling.
Sourcepub fn try_register(
&mut self,
tool: impl Tool + 'static,
) -> Result<&mut Self, PeError>
pub fn try_register( &mut self, tool: impl Tool + 'static, ) -> Result<&mut Self, PeError>
Fallible registration path for dynamic/runtime-owned insertion.
Sourcepub fn try_register_arc(
&mut self,
tool: Arc<dyn Tool>,
) -> Result<&mut Self, PeError>
pub fn try_register_arc( &mut self, tool: Arc<dyn Tool>, ) -> Result<&mut Self, PeError>
Fallible registration path for pre-wrapped Arc<dyn Tool>.
Sourcepub fn schemas(&self) -> Vec<ToolSchema>
pub fn schemas(&self) -> Vec<ToolSchema>
Produce ToolSchema list for the LLM — all registered tools.
Sourcepub fn filter(&self, names: &[&str]) -> ToolRegistry
pub fn filter(&self, names: &[&str]) -> ToolRegistry
Create a subset registry containing only tools with the given names.
Used by ToolPolicy::filter() to enforce per-agent tool allowlists.
Tools not found in this registry are silently skipped.
Trait Implementations§
Source§impl Clone for ToolRegistry
impl Clone for ToolRegistry
Source§impl Debug for ToolRegistry
impl Debug for ToolRegistry
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