pub struct ToolRegistry { /* private fields */ }Expand description
Registry of named tools with their async handlers.
Implements Dispatcher directly — tools() returns schemas and
dispatch() looks up handlers by name. Used as both the runtime’s
shared store and the per-agent dispatcher snapshot.
Implementations§
Source§impl ToolRegistry
impl ToolRegistry
Sourcepub fn new() -> ToolRegistry
pub fn new() -> ToolRegistry
Create an empty registry.
Sourcepub fn insert(
&mut self,
tool: Tool,
handler: Arc<dyn Fn(String) -> Pin<Box<dyn Future<Output = String> + Send>> + Sync + Send>,
)
pub fn insert( &mut self, tool: Tool, handler: Arc<dyn Fn(String) -> Pin<Box<dyn Future<Output = String> + Send>> + Sync + Send>, )
Insert a tool and its handler.
Sourcepub fn remove(&mut self, name: &str) -> bool
pub fn remove(&mut self, name: &str) -> bool
Remove a tool by name. Returns true if it existed.
Sourcepub fn iter(
&self,
) -> impl Iterator<Item = (&Tool, &Arc<dyn Fn(String) -> Pin<Box<dyn Future<Output = String> + Send>> + Sync + Send>)>
pub fn iter( &self, ) -> impl Iterator<Item = (&Tool, &Arc<dyn Fn(String) -> Pin<Box<dyn Future<Output = String> + Send>> + Sync + Send>)>
Iterate over all (Tool, Handler) pairs.
Sourcepub fn filtered_snapshot(&self, names: &[CompactString]) -> ToolRegistry
pub fn filtered_snapshot(&self, names: &[CompactString]) -> ToolRegistry
Build a filtered snapshot containing only the named tools.
If names is empty, all tools are included. Used by runtime to
build a per-agent dispatcher.
Trait Implementations§
Source§impl Clone for ToolRegistry
impl Clone for ToolRegistry
Source§fn clone(&self) -> ToolRegistry
fn clone(&self) -> ToolRegistry
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Default for ToolRegistry
impl Default for ToolRegistry
Source§fn default() -> ToolRegistry
fn default() -> ToolRegistry
Returns the “default value” for a type. Read more
Source§impl Dispatcher for ToolRegistry
impl Dispatcher for ToolRegistry
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