pub struct Tools { /* private fields */ }Expand description
Implementations§
Source§impl Tools
impl Tools
Sourcepub fn get<T>(&self) -> Option<&T>where
T: Tool + 'static,
pub fn get<T>(&self) -> Option<&T>where
T: Tool + 'static,
Retrieves a tool by type.
Returns None if the tool is not found.
Sourcepub fn get_mut<T>(&mut self) -> Option<&mut T>where
T: Tool + 'static,
pub fn get_mut<T>(&mut self) -> Option<&mut T>where
T: Tool + 'static,
Retrieves a mutable reference to a tool by type.
Returns None if the tool is not found.
Sourcepub fn definitions(&self) -> Vec<ToolDefinition>
pub fn definitions(&self) -> Vec<ToolDefinition>
Returns definitions of all registered tools.
Sourcepub fn register<T: Tool + 'static>(
&mut self,
tool: T,
) -> Result<(), RegisterError>
pub fn register<T: Tool + 'static>( &mut self, tool: T, ) -> Result<(), RegisterError>
Registers a new tool.
The tool must implement Tool and be 'static.
§Errors
Returns RegisterError::DuplicateName if a tool of that name is
already registered, or RegisterError::EmptyDescription if the tool
has no description — a model cannot use a tool it cannot read about, so
this is rejected rather than silently passed on.
Sourcepub fn register_dyn<F>(
&mut self,
definition: ToolDefinition,
handler: F,
) -> Result<(), RegisterError>
pub fn register_dyn<F>( &mut self, definition: ToolDefinition, handler: F, ) -> Result<(), RegisterError>
Registers a dynamic tool with a pre-made definition and handler.
This is useful for type-erased tools (e.g., child terminal tools for subagents) where the concrete type isn’t known at compile time.
§Errors
Same conditions as Self::register.
Sourcepub fn unregister(&mut self, name: &str)
pub fn unregister(&mut self, name: &str)
Removes a tool from the registry.