#[tool]Expand description
The #[tool] attribute macro for defining tools.
This macro transforms a regular Rust function into a tool that can be used with the mistral.rs agentic loop. It generates:
{fn_name}_tool()- Returns theTooldefinition{fn_name}_callback()- Returns anArc<ToolCallback>that wraps the function{fn_name}_tool_with_callback()- Returns both as a tuple
§Attributes
description(required): A description of what the tool doesname(optional): Override the tool name (defaults to function name)
§Parameter Attributes
#[description = "..."]: Description of the parameter#[default = value]: Default value if parameter is optional
§Requirements
- All parameter types must implement
serde::Deserializeandschemars::JsonSchema - The return type must be
Result<T>oranyhow::Result<T>whereT: Serialize - For async functions, ensure a tokio runtime is available