Macro rustler::rustler_export_nifs[][src]

macro_rules! rustler_export_nifs {
    ($name:expr, [$( $exported_nif:tt ),+,], $on_load:expr) => { ... };
    ($name:expr, [$( $exported_nif:tt ),*], $on_load:expr) => { ... };
    (internal_item_init, ($nif_name:expr, $nif_arity:expr, $nif_fun:path)) => { ... };
    (internal_item_init, ($nif_name:expr, $nif_arity:expr, $nif_fun:path, $nif_flag:expr)) => { ... };
    (internal_platform_init, ($inner:expr)) => { ... };

Exports a given list of functions to a Erlang module.

This should be called exactly once in every NIF library. It will wrap and export the given rust functions into the Erlang module.

The first argument is a string specifying what Erlang/Elixir module you want the function exported into. In Erlang this will simply be the atom you named your module. In Elixir, all modules are prefixed with Elixir.<module path>

The second argument is a list of 3-tuples. Each tuple contains information on a single exported NIF function. The first tuple item is the name you want to export the function into, the second is the arity (number of arguments) of the exported function. The third argument is a indentifier of a rust function. This is where your actual NIF will be implemented.

The third argument is an Option<fn(env: &Env, load_info: Term) -> bool>. If this is Some, the function will execute when the NIF is first loaded by the BEAM.