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
}
}