pub struct ToolRegistry { /* private fields */ }Expand description
Registry of tools with optional middleware pipelines.
Tools are stored as type-erased ToolDyn trait objects.
Middleware can be added globally (applies to all tools) or per-tool.
Implementations§
Source§impl ToolRegistry
impl ToolRegistry
Sourcepub fn register<T: Tool + 'static>(&mut self, tool: T)
pub fn register<T: Tool + 'static>(&mut self, tool: T)
Register a strongly-typed tool (auto-erased to ToolDyn).
Sourcepub fn register_dyn(&mut self, tool: Arc<dyn ToolDyn>)
pub fn register_dyn(&mut self, tool: Arc<dyn ToolDyn>)
Register a pre-erased tool.
Sourcepub fn definitions(&self) -> Vec<ToolDefinition>
pub fn definitions(&self) -> Vec<ToolDefinition>
Get definitions for all registered tools.
Sourcepub fn add_middleware(&mut self, m: impl ToolMiddleware + 'static) -> &mut Self
pub fn add_middleware(&mut self, m: impl ToolMiddleware + 'static) -> &mut Self
Add global middleware (applies to all tool executions).
Sourcepub fn add_tool_middleware(
&mut self,
tool_name: &str,
m: impl ToolMiddleware + 'static,
) -> &mut Self
pub fn add_tool_middleware( &mut self, tool_name: &str, m: impl ToolMiddleware + 'static, ) -> &mut Self
Add middleware that only applies to a specific tool.
Sourcepub async fn execute(
&self,
name: &str,
input: Value,
ctx: &ToolContext,
) -> Result<ToolOutput, ToolError>
pub async fn execute( &self, name: &str, input: Value, ctx: &ToolContext, ) -> Result<ToolOutput, ToolError>
Execute a tool by name, running it through the middleware chain.
Middleware order: global middleware first, then per-tool middleware, then the actual tool.
Trait Implementations§
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