pub struct ToolRegistry<Ctx> { /* private fields */ }Expand description
Implementations§
Source§impl<Ctx: Send + Sync + 'static> ToolRegistry<Ctx>
impl<Ctx: Send + Sync + 'static> ToolRegistry<Ctx>
pub fn new() -> Self
Sourcepub fn register<T>(&mut self, tool: T) -> &mut Selfwhere
T: Tool<Ctx> + 'static,
pub fn register<T>(&mut self, tool: T) -> &mut Selfwhere
T: Tool<Ctx> + 'static,
Register a synchronous tool in the registry.
The tool’s name is converted to a string via serde serialization and used as the lookup key.
Sourcepub fn register_async<T>(&mut self, tool: T) -> &mut Selfwhere
T: AsyncTool<Ctx> + 'static,
pub fn register_async<T>(&mut self, tool: T) -> &mut Selfwhere
T: AsyncTool<Ctx> + 'static,
Register an async tool in the registry.
Async tools have two phases: execute (lightweight, starts operation)
and check_status (streams progress until completion).
Sourcepub fn get(&self, name: &str) -> Option<&Arc<dyn ErasedTool<Ctx>>>
pub fn get(&self, name: &str) -> Option<&Arc<dyn ErasedTool<Ctx>>>
Get a synchronous tool by name.
Sourcepub fn get_async(&self, name: &str) -> Option<&Arc<dyn ErasedAsyncTool<Ctx>>>
pub fn get_async(&self, name: &str) -> Option<&Arc<dyn ErasedAsyncTool<Ctx>>>
Get an async tool by name.
Sourcepub fn all(&self) -> impl Iterator<Item = &Arc<dyn ErasedTool<Ctx>>>
pub fn all(&self) -> impl Iterator<Item = &Arc<dyn ErasedTool<Ctx>>>
Get all registered synchronous tools.
Sourcepub fn all_async(&self) -> impl Iterator<Item = &Arc<dyn ErasedAsyncTool<Ctx>>>
pub fn all_async(&self) -> impl Iterator<Item = &Arc<dyn ErasedAsyncTool<Ctx>>>
Get all registered async tools.
Sourcepub fn to_llm_tools(&self) -> Vec<Tool>
pub fn to_llm_tools(&self) -> Vec<Tool>
Convert all tools (sync + async) to LLM tool definitions.
Trait Implementations§
Source§impl<Ctx> Clone for ToolRegistry<Ctx>
impl<Ctx> Clone for ToolRegistry<Ctx>
Auto Trait Implementations§
impl<Ctx> Freeze for ToolRegistry<Ctx>
impl<Ctx> !RefUnwindSafe for ToolRegistry<Ctx>
impl<Ctx> Send for ToolRegistry<Ctx>
impl<Ctx> Sync for ToolRegistry<Ctx>
impl<Ctx> Unpin for ToolRegistry<Ctx>
impl<Ctx> !UnwindSafe for ToolRegistry<Ctx>
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