pub struct ToolRegistry { /* private fields */ }Expand description
Registry of available tools, keyed by name.
Implementations§
Source§impl ToolRegistry
impl ToolRegistry
Sourcepub fn register(
&mut self,
spec: ToolSpec,
handler: ToolFn,
) -> Result<(), AgentError>
pub fn register( &mut self, spec: ToolSpec, handler: ToolFn, ) -> Result<(), AgentError>
Registers a tool with its specification and handler.
§Errors
Returns AgentError::InvalidToolSignature if the tool name is empty.
Sourcepub fn dispatch(
&self,
tool_name: &str,
input: &str,
) -> Result<ToolResult, AgentError>
pub fn dispatch( &self, tool_name: &str, input: &str, ) -> Result<ToolResult, AgentError>
Dispatches a tool call by name with the given JSON input string.
§Errors
Returns AgentError::ToolNotFound if no tool with that name is registered.
Sourcepub fn spec(&self, name: &str) -> Option<&ToolSpec>
pub fn spec(&self, name: &str) -> Option<&ToolSpec>
Returns the spec for a registered tool, or None if not found.
Sourcepub fn tool_count(&self) -> usize
pub fn tool_count(&self) -> usize
Returns the number of registered tools.
Sourcepub fn tool_names(&self) -> Vec<&str>
pub fn tool_names(&self) -> Vec<&str>
Returns the names of all registered tools.
Sourcepub fn tools_prompt(&self) -> String
pub fn tools_prompt(&self) -> String
Generates a system-prompt snippet listing all registered tools.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for ToolRegistry
impl !Send for ToolRegistry
impl !Sync for ToolRegistry
impl !UnwindSafe for ToolRegistry
impl Freeze 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