Tool

Trait Tool 

Source
pub trait Tool:
    Send
    + Sync
    + Default {
    type Params: Serialize + for<'de> Deserialize<'de> + JsonSchema;

    // Required methods
    fn name(&self) -> &str;
    fn execute_typed(
        &self,
        params: Self::Params,
        context: &mut ToolContext<'_>,
    ) -> Result<ToolResult>;

    // Provided methods
    fn parameters_schema(&self) -> Value { ... }
    fn execute(
        &self,
        params: Value,
        context: &mut ToolContext<'_>,
    ) -> Result<ToolResult> { ... }
}
Expand description

Trait for browser automation tools with associated parameter types

Required Associated Types§

Source

type Params: Serialize + for<'de> Deserialize<'de> + JsonSchema

Associated parameter type for this tool

Required Methods§

Source

fn name(&self) -> &str

Get tool name

Source

fn execute_typed( &self, params: Self::Params, context: &mut ToolContext<'_>, ) -> Result<ToolResult>

Execute the tool with strongly-typed parameters

Provided Methods§

Source

fn parameters_schema(&self) -> Value

Get tool parameter schema (JSON Schema)

Source

fn execute( &self, params: Value, context: &mut ToolContext<'_>, ) -> Result<ToolResult>

Execute the tool with JSON parameters (default implementation)

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§