pub trait SkillExecutor: Send + Sync {
// Required methods
fn execute_tool<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
skill_id: &'life1 str,
tool_name: &'life2 str,
args: Value,
) -> Pin<Box<dyn Future<Output = Result<ToolOutput, SkillError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn tools(&self, skill_id: &str) -> Result<Vec<ToolDefinition>, SkillError>;
}Expand description
Skill tool executor.
Executes a single named tool within a skill identified by skill_id.
This trait does not run an LLM loop — it only handles one tool call
at a time. Callers are responsible for any higher-level orchestration.
§Example
ⓘ
use async_trait::async_trait;
use xz_skill_core::traits::{SkillExecutor, ToolOutput};
use xz_skill_core::SkillError;
use xz_skill_core::types::skill::ToolDefinition;
struct EchoExecutor;
#[async_trait]
impl SkillExecutor for EchoExecutor {
async fn execute_tool(
&self,
_skill_id: &str,
tool_name: &str,
args: serde_json::Value,
) -> Result<ToolOutput, SkillError> {
Ok(ToolOutput {
output: format!("{}: {}", tool_name, args),
is_error: false,
})
}
fn tools(&self, _skill_id: &str) -> Result<Vec<ToolDefinition>, SkillError> {
Ok(vec![ToolDefinition {
name: "echo".into(),
description: "Echoes input".into(),
input_schema: serde_json::json!({}),
tool_type: crate::types::skill::ToolType::Builtin {
handler: "echo".into(),
},
}])
}
}Required Methods§
Sourcefn execute_tool<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
skill_id: &'life1 str,
tool_name: &'life2 str,
args: Value,
) -> Pin<Box<dyn Future<Output = Result<ToolOutput, SkillError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn execute_tool<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
skill_id: &'life1 str,
tool_name: &'life2 str,
args: Value,
) -> Pin<Box<dyn Future<Output = Result<ToolOutput, SkillError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Execute a single named tool with the given arguments.
skill_id— Identifies which skill provides the tool.tool_name— The name of the tool to invoke.args— JSON arguments passed to the tool.
Sourcefn tools(&self, skill_id: &str) -> Result<Vec<ToolDefinition>, SkillError>
fn tools(&self, skill_id: &str) -> Result<Vec<ToolDefinition>, SkillError>
List all tools available for a given skill.
Returns the tool definitions so callers can discover capabilities without executing anything.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".