pub struct ToolRegistry { /* private fields */ }Expand description
Registry of available tools, keyed by name.
Implementations§
Source§impl ToolRegistry
impl ToolRegistry
pub fn new() -> Self
Sourcepub fn register(&mut self, tool: Box<dyn Tool>)
pub fn register(&mut self, tool: Box<dyn Tool>)
Register a tool. Overwrites any existing tool with the same name.
Sourcepub fn execute(&self, call: &ToolCall) -> Result<ToolResult, AgentError>
pub fn execute(&self, call: &ToolCall) -> Result<ToolResult, AgentError>
Execute a tool call, returning the result.
Sourcepub fn iter(&self) -> impl Iterator<Item = &dyn Tool>
pub fn iter(&self) -> impl Iterator<Item = &dyn Tool>
Returns an iterator over all registered tools.
Sourcepub fn tools_prompt(&self) -> String
pub fn tools_prompt(&self) -> String
Generate a system prompt fragment describing all available tools.
This produces JSON tool descriptions that can be appended to the system prompt so the model knows what tools are available and how to call them.
pub fn is_empty(&self) -> bool
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