Skip to main content

ToolResources

Trait ToolResources 

Source
pub trait ToolResources: Send + Sync {
    // Required method
    fn as_any(&self) -> &dyn Any;
}
Expand description

Trait for dependency injection into tool implementations.

Tools that need access to shared state (database handles, HTTP clients, configuration, etc.) can downcast the &dyn ToolResources provided in ToolContext to a concrete type.

The unit type () implements ToolResources and serves as the default when no shared resources are needed.

§Example

use std::any::Any;
use agentkit_tools_core::ToolResources;

struct AppResources {
    project_root: std::path::PathBuf,
}

impl ToolResources for AppResources {
    fn as_any(&self) -> &dyn Any {
        self
    }
}

Required Methods§

Source

fn as_any(&self) -> &dyn Any

Returns a reference to self as Any so callers can downcast to the concrete resource type.

Implementations on Foreign Types§

Source§

impl ToolResources for ()

Source§

fn as_any(&self) -> &dyn Any

Implementors§