Skip to main content

ScalarFunction

Trait ScalarFunction 

Source
pub trait ScalarFunction<'db> {
    // Required method
    fn call(&self, context: &Context, args: &mut [&mut ValueRef]) -> Result<()>;
}
Expand description

Trait for scalar functions. This trait is used with Connection::create_scalar_function_object to implement scalar functions that have a lifetime smaller than 'static. It is also possible to use closures and avoid implementing this trait, see Connection::create_scalar_function for details.

Required Methods§

Source

fn call(&self, context: &Context, args: &mut [&mut ValueRef]) -> Result<()>

Perform a single invocation. The function will be invoked with a Context and an array of ValueRef objects. The function is required to set its output using Context::set_result. If no result is set, SQL NULL is returned. If the function returns an Err value, the SQL statement will fail, even if a result had been set.

Implementors§