Skip to main content

rskit_tool/
callable.rs

1//! Callable trait — type-erased tool interface.
2
3use async_trait::async_trait;
4use rskit_errors::AppResult;
5use rskit_schema::ValidationResult;
6
7use crate::context::Context;
8use crate::definition::Definition;
9use crate::io::ToolInput;
10use crate::result::ToolResult;
11
12/// Type-erased tool interface for heterogeneous registries.
13#[async_trait]
14pub trait Callable: Send + Sync {
15    /// Return the tool's metadata.
16    fn definition(&self) -> &Definition;
17
18    /// Validate input against the tool's input schema.
19    fn validate(&self, input: &ToolInput) -> ValidationResult;
20
21    /// Execute the tool with a context and JSON input.
22    async fn call(&self, ctx: &Context, input: ToolInput) -> AppResult<ToolResult>;
23}