pub trait ToolExecutor: Send + Sync {
// Required methods
fn execute<'life0, 'async_trait>(
&'life0 self,
request: ToolRequest,
) -> Pin<Box<dyn Future<Output = Layer3Result<ToolResponse>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn execute_batch<'life0, 'async_trait>(
&'life0 self,
requests: Vec<ToolRequest>,
) -> Pin<Box<dyn Future<Output = Layer3Result<Vec<ToolResponse>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn is_available(&self, name: &str) -> bool;
fn get_meta(&self, name: &str) -> Option<ToolMeta>;
fn list_tools(&self) -> Vec<ToolMeta>;
}Expand description
工具执行器 trait
定义工具执行的核心接口。实现者负责:
- 接收工具调用请求
- 验证参数
- 执行工具逻辑
- 返回执行结果
Required Methods§
Sourcefn execute<'life0, 'async_trait>(
&'life0 self,
request: ToolRequest,
) -> Pin<Box<dyn Future<Output = Layer3Result<ToolResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn execute<'life0, 'async_trait>(
&'life0 self,
request: ToolRequest,
) -> Pin<Box<dyn Future<Output = Layer3Result<ToolResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Sourcefn execute_batch<'life0, 'async_trait>(
&'life0 self,
requests: Vec<ToolRequest>,
) -> Pin<Box<dyn Future<Output = Layer3Result<Vec<ToolResponse>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn execute_batch<'life0, 'async_trait>(
&'life0 self,
requests: Vec<ToolRequest>,
) -> Pin<Box<dyn Future<Output = Layer3Result<Vec<ToolResponse>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Sourcefn is_available(&self, name: &str) -> bool
fn is_available(&self, name: &str) -> bool
Sourcefn list_tools(&self) -> Vec<ToolMeta>
fn list_tools(&self) -> Vec<ToolMeta>
获取所有已注册工具的元数据
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".