Tool Registry • Rust AI Agent SDK
ToolRegistry: Registry for managing tools
ToolRegistry
Defined in the tools module.
Rust AI Agent SDK
Registry for managing tools
%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#8B0000', 'primaryTextColor': '#fff', 'primaryBorderColor': '#710101', 'lineColor': '#189AB4', 'secondaryColor': '#189AB4', 'tertiaryColor': '#fff' }}}%%
graph LR
agent["Agent"] -- "uses" --> tool["Tool: ToolRegistry"]
tool -- "returns" --> result["Result"]
style tool fill:#189AB4,color:#fff
style agent fill:#8B0000,color:#fff
style result fill:#8B0000,color:#fffFields
| Name | Type | Description |
|---|---|---|
tools | HashMap<String | – |
Methods
new
fn new() -> SelfCreate a new empty registry
register
fn register(&mut self, tool: impl Tool + 'static) -> ()Register a tool
Parameters:
| Name | Type |
|---|---|
tool | impl Tool + 'static |
get
fn get(&self, name: &str) -> Option<Arc<dyn Tool>>Get a tool by name
Parameters:
| Name | Type |
|---|---|
name | &str |
has
fn has(&self, name: &str) -> boolCheck if a tool exists
Parameters:
| Name | Type |
|---|---|
name | &str |
list
fn list(&self) -> Vec<&str>List all tool names
definitions
fn definitions(&self) -> Vec<ToolDefinition>Get all tool definitions
execute
async fn execute(&self, name: &str, args: Value) -> Result<ToolResult>Execute a tool by name
Parameters:
| Name | Type |
|---|---|
name | &str |
args | Value |
len
fn len(&self) -> usizeGet the number of registered tools
is_empty
fn is_empty(&self) -> boolCheck if the registry is empty
Source
View on GitHubpraisonai/src/tools/mod.rs at line 101