pub struct ToolRegistry { /* private fields */ }Expand description
A registry for dynamically managing agent tools.
Tools are registered under their AgentTool::name and can be retrieved,
listed, or have their inputs validated against their parameter schemas.
Implementations§
Source§impl ToolRegistry
impl ToolRegistry
Sourcepub fn register(&mut self, tool: Arc<dyn AgentTool>)
pub fn register(&mut self, tool: Arc<dyn AgentTool>)
Registers a tool in the registry, replacing any existing tool with the same name.
Sourcepub fn get(&self, name: &str) -> Option<&dyn AgentTool>
pub fn get(&self, name: &str) -> Option<&dyn AgentTool>
Retrieves a tool by name, or None if not registered.
Sourcepub fn validate_input(&self, name: &str, input: &Value) -> Result<(), ToolError>
pub fn validate_input(&self, name: &str, input: &Value) -> Result<(), ToolError>
Validates that the given input conforms to the tool’s parameter schema.
Returns Ok(()) if the tool exists and the input is an object, or
Err(ToolError) if the tool is not found or the input is invalid.
This performs a basic structural check (input must be a JSON object).
Full JSON Schema validation can be added later via the jsonschema crate.
Trait Implementations§
Source§impl Default for ToolRegistry
impl Default for ToolRegistry
Source§fn default() -> ToolRegistry
fn default() -> ToolRegistry
Returns the “default value” for a type. Read more
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