Function convert_value_to_type

Source
pub fn convert_value_to_type<T>(value: &Value) -> Result<T>
where T: ValueConverter,
Expand description

Convert a Value to a native Rust type based on the expected type T.

This utility function simplifies converting Value instances to native Rust types in function implementations.

This function is typically used internally by the function registration macros in crate::macros and is automatically called when functions are invoked.

§Arguments

  • value - The value to convert

§Returns

Returns a Result<T> containing the converted value or an error if conversion fails.

§Example

use aimx::{function_registry::convert_value_to_type, Value, Literal};

let value = Value::from(42.0);
let number: f64 = convert_value_to_type(&value).unwrap();
assert_eq!(number, 42.0);