Skip to main content

CustomFunction

Trait CustomFunction 

Source
pub trait CustomFunction: Send + Sync {
    // Required methods
    fn execute(&self, args: &[Value]) -> Result<Value, Error>;
    fn name(&self) -> &str;

    // Provided methods
    fn description(&self) -> &str { ... }
    fn arity(&self) -> Option<usize> { ... }
    fn validate_args(&self, args: &[Value]) -> Result<(), Error> { ... }
}
Expand description

Trait for custom function implementations

Required Methods§

Source

fn execute(&self, args: &[Value]) -> Result<Value, Error>

Execute the custom function with given arguments

Source

fn name(&self) -> &str

Get function name

Provided Methods§

Source

fn description(&self) -> &str

Get function description

Source

fn arity(&self) -> Option<usize>

Get expected argument count (None = variadic)

Source

fn validate_args(&self, args: &[Value]) -> Result<(), Error>

Validate arguments before execution

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§