pub struct ToolRegistry { /* private fields */ }Implementations§
Source§impl ToolRegistry
impl ToolRegistry
pub fn register(&mut self, tool: impl Tool + 'static)
pub fn register_arc(&mut self, tool: Arc<dyn Tool>)
pub fn get(&self, name: &str) -> Option<Arc<dyn Tool>>
Sourcepub fn defer(&mut self, name: &str) -> Option<Value>
pub fn defer(&mut self, name: &str) -> Option<Value>
Mark name to mount as deferred whenever it appears, and wrap it now if
it is already registered. Returns the rendered definition — what
crate::tool::ActivateTool hands back on open — or None when the
tool is not registered yet. The mark still holds, so a later
registration is deferred too.
Sourcepub fn deferred_defs(&self) -> Arc<RwLock<HashMap<String, Value>>> ⓘ
pub fn deferred_defs(&self) -> Arc<RwLock<HashMap<String, Value>>> ⓘ
The shared deferred-definition catalog: name -> rendered definition,
filled whenever a deferred-marked tool is (or becomes) registered.
Hand it to crate::tool::ActivateTool so late registrations stay
openable — see the field docs for why it is shared and not a copy.
pub fn definitions(&self) -> Vec<Value>
Sourcepub fn definitions_filtered(&self, ctx: &ActivationContext) -> Vec<Value>
pub fn definitions_filtered(&self, ctx: &ActivationContext) -> Vec<Value>
Return tool definitions filtered by ToolExposure.
Directtools are always included.Deferredtools are included only whenshould_activate(ctx)returnstrue.Hiddentools are never included.
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn metadatas(&self) -> Vec<ToolMetadata>
pub fn metadatas(&self) -> Vec<ToolMetadata>
Collect metadata for every registered tool, sorted by name.
This is the preferred introspection API for consumers — it returns a
stable ToolMetadata struct per tool instead of having callers parse
the LLM-facing JSON definitions.