Trait FunctionHandler

Source
pub trait FunctionHandler: Send + Sync {
    // Required method
    fn call(
        &self,
        context: &mut dyn ContextLike,
        args: &[Value],
    ) -> Result<Value>;
}
Expand description

Trait for function handlers.

This trait defines the interface that all function handlers must implement. Function handlers are responsible for executing the actual function logic and returning the result as a Value.

This trait is automatically implemented when using the function registration macros in crate::macros.

Required Methods§

Source

fn call(&self, context: &mut dyn ContextLike, args: &[Value]) -> Result<Value>

Call the function with the provided arguments.

§Arguments
  • context - The evaluation context for closures
  • args - A slice of Value arguments passed to the function
§Returns

Returns a Result<Value> containing the function result or an error if the function execution fails.

§Note

For method calls, the first argument is typically the value the method is being called on, followed by any additional arguments.

Implementors§