pub trait ToolFunction:
Send
+ Sync
+ 'static {
// Required methods
fn name(&self) -> &str;
fn description(&self) -> &str;
fn parameters(&self) -> Option<Value>;
fn call<'life0, 'async_trait>(
&'life0 self,
args: Value,
) -> Pin<Box<dyn Future<Output = Result<Value, ToolError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Expand description
A regular tool — called once, returns a result.
§Examples
ⓘ
use async_trait::async_trait;
use gemini_adk_rs::tool::ToolFunction;
use gemini_adk_rs::error::ToolError;
struct MyTool;
#[async_trait]
impl ToolFunction for MyTool {
fn name(&self) -> &str { "my_tool" }
fn description(&self) -> &str { "Does something useful" }
fn parameters(&self) -> Option<serde_json::Value> { None }
async fn call(&self, args: serde_json::Value) -> Result<serde_json::Value, ToolError> {
Ok(serde_json::json!({"status": "ok"}))
}
}Required Methods§
Sourcefn description(&self) -> &str
fn description(&self) -> &str
Human-readable description of what this tool does.
Sourcefn parameters(&self) -> Option<Value>
fn parameters(&self) -> Option<Value>
JSON Schema for the tool’s input parameters, or None if parameterless.