Attribute Macro scylla_udf::export_udf

source ·
#[export_udf]
Expand description

This macro allows using a Rust function as a Scylla UDF.

The function must have arguments and return value of Rust types that can be mapped to CQL types, the macro takes care of converting the arguments from CQL types to Rust types and back. The function must not have the #[no_mangle] attribute, it will be added by the macro.

For example, for a function:

#[scylla_udf::export_udf]
fn foo(arg: i32) -> i32 {
   arg + 1
}

you can use the compiled binary in its text format as a UDF in Scylla:

CREATE FUNCTION foo(arg int) RETURNS NULL ON NULL INPUT RETURNS int LANGUAGE rust AS '(module ...)`;