Skip to main content

Tool

Trait Tool 

Source
pub trait Tool: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn gana(&self) -> Gana;
    fn effects(&self) -> &EffectRow;
    fn call<'life0, 'life1, 'async_trait>(
        &'life0 self,
        ctx: &'life1 mut Context,
        args: Args,
    ) -> Pin<Box<dyn Future<Output = Result<Output>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn stats(&self) -> &ToolStats;

    // Provided methods
    fn description(&self) -> &str { ... }
    fn input_schema(&self) -> Value { ... }
}
Expand description

The core tool trait. Every WhiteMagic tool implements this.

Tools declare their Gana affiliation and effect row, then implement the call method. The dispatch pipeline handles routing, governance, and statistics tracking.

Required Methods§

Source

fn name(&self) -> &str

Unique tool name (e.g., “memory.create”, “search.hybrid”)

Source

fn gana(&self) -> Gana

Which Gana this tool belongs to.

Source

fn effects(&self) -> &EffectRow

Effect row — what this tool does to the world.

Source

fn call<'life0, 'life1, 'async_trait>( &'life0 self, ctx: &'life1 mut Context, args: Args, ) -> Pin<Box<dyn Future<Output = Result<Output>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Execute the tool.

Source

fn stats(&self) -> &ToolStats

Access this tool’s statistics.

Provided Methods§

Source

fn description(&self) -> &str

Human-readable description.

Source

fn input_schema(&self) -> Value

JSON-Schema-style description of the accepted arguments.

Defaults to an empty object (no schema). Curated tools override this so tools.list can show clients the argument contract.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§