pub struct ToolRegistry { /* private fields */ }Expand description
In-memory registry of executable tools.
Implementations§
Source§impl ToolRegistry
impl ToolRegistry
pub fn new() -> Self
Sourcepub fn register_from_file(
&mut self,
definition_path: impl AsRef<Path>,
implementation: impl Tool + 'static,
) -> Result<(), ConfigError>
pub fn register_from_file( &mut self, definition_path: impl AsRef<Path>, implementation: impl Tool + 'static, ) -> Result<(), ConfigError>
Load a tool definition from TOML and register it with its implementation.
This is the standard registration path for tool integration crates: the definition is parsed, its JSON Schema is compiled, and the implementation is bound to the definition in one operation.
Sourcepub fn register(
&mut self,
definition: ToolDefinition,
implementation: impl Tool + 'static,
) -> Result<(), ConfigError>
pub fn register( &mut self, definition: ToolDefinition, implementation: impl Tool + 'static, ) -> Result<(), ConfigError>
Register an already constructed definition.
This is useful for programmatic tools and tests. Integration crates
should normally use register_from_file so metadata loading follows
the same convention everywhere.
Sourcepub fn contains(&self, name: &str) -> bool
pub fn contains(&self, name: &str) -> bool
Returns whether an executable implementation is registered for the given name.
pub fn definition(&self, name: &str) -> Option<ToolDefinition>
Sourcepub fn definitions(&self) -> Vec<ToolDefinition>
pub fn definitions(&self) -> Vec<ToolDefinition>
Returns the definitions of all registered tools.
Trait Implementations§
Source§impl Default for ToolRegistry
impl Default for ToolRegistry
Source§impl ToolDispatcher for ToolRegistry
impl ToolDispatcher for ToolRegistry
fn definition(&self, name: &str) -> Option<ToolDefinition>
fn execute<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
context: &'life1 ToolContext,
name: &'life2 str,
arguments: Value,
) -> Pin<Box<dyn Future<Output = Result<String, ToolError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Auto Trait Implementations§
impl !RefUnwindSafe for ToolRegistry
impl !UnwindSafe for ToolRegistry
impl Freeze for ToolRegistry
impl Send for ToolRegistry
impl Sync 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