pub struct ToolDefinition {
pub id: String,
pub name: String,
pub category: ToolCategory,
pub risk_score: f64,
pub requires_approval: bool,
pub rate_limit: Option<u32>,
pub required_permissions: Vec<String>,
pub description: String,
}Expand description
Definition of a tool with security metadata.
Each tool registered in the ToolRegistry carries metadata that the
security engine uses to assess risk, enforce rate limits, and decide
whether user approval is required.
Fields§
§id: StringUnique tool identifier (e.g., "web_search", "file_read").
name: StringHuman-readable name.
category: ToolCategorySecurity category.
risk_score: f64Risk score 0.0–1.0 (0 = safe, 1 = dangerous).
requires_approval: boolWhether this tool requires explicit user approval before execution.
rate_limit: Option<u32>Maximum calls per minute (None = unlimited).
required_permissions: Vec<String>List of permission strings required to use this tool.
description: StringDescription of what this tool does.
Implementations§
Source§impl ToolDefinition
impl ToolDefinition
Sourcepub fn new(id: &str, name: &str, category: ToolCategory) -> Self
pub fn new(id: &str, name: &str, category: ToolCategory) -> Self
Create a new tool definition with sensible defaults.
The risk score defaults to 0.5, approval is not required, and
no per-tool rate limit is set.
Sourcepub fn with_risk_score(self, score: f64) -> Self
pub fn with_risk_score(self, score: f64) -> Self
Set the risk score (clamped to 0.0–1.0).
Sourcepub fn with_requires_approval(self, requires: bool) -> Self
pub fn with_requires_approval(self, requires: bool) -> Self
Set whether this tool requires user approval.
Sourcepub fn with_rate_limit(self, limit: u32) -> Self
pub fn with_rate_limit(self, limit: u32) -> Self
Set a per-tool rate limit (calls per minute).
Sourcepub fn with_permission(self, permission: String) -> Self
pub fn with_permission(self, permission: String) -> Self
Add a required permission string.
Sourcepub fn with_description(self, description: String) -> Self
pub fn with_description(self, description: String) -> Self
Set the tool description.
Trait Implementations§
Source§impl Clone for ToolDefinition
impl Clone for ToolDefinition
Source§fn clone(&self) -> ToolDefinition
fn clone(&self) -> ToolDefinition
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more