quick_tool

Macro quick_tool 

Source
macro_rules! quick_tool {
    (
        name: $name:ident,
        description: $desc:expr,
        params: ($($param_name:ident: $param_type:tt),* $(,)?),
        execute: |$($param_var:ident),*| $body:expr
    ) => { ... };
    (@extract $args:ident, $name:expr, i32) => { ... };
    (@extract $args:ident, $name:expr, i64) => { ... };
    (@extract $args:ident, $name:expr, u32) => { ... };
    (@extract $args:ident, $name:expr, u64) => { ... };
    (@extract $args:ident, $name:expr, f32) => { ... };
    (@extract $args:ident, $name:expr, f64) => { ... };
    (@extract $args:ident, $name:expr, bool) => { ... };
    (@extract $args:ident, $name:expr, String) => { ... };
}
Expand description

Quick tool creation with auto-derived types.

This is the simplest way to create a tool - just provide the function signature and body, and everything else is handled automatically.

ยงExample

use helios_engine::quick_tool;

let tool = quick_tool! {
    name: calculate_volume,
    description: "Calculate the volume of a box",
    params: (width: f64, height: f64, depth: f64),
    execute: |width, height, depth| {
        format!("Volume: {} cubic meters", width * height * depth)
    }
};