alef 0.25.1

Opinionated polyglot binding generator for Rust libraries
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
#[rustler::nif(schedule = "DirtyCpu")]
pub fn {{ register_fn }}(env: rustler::Env<'_>, genserver_pid: rustler::LocalPid, plugin_name: String) -> rustler::Atom {
    let wrapper = {{ wrapper_name }}::new(genserver_pid, plugin_name);
    let arc: std::sync::Arc<dyn {{ trait_path }}> = std::sync::Arc::new(wrapper);

    match {{ registry_getter }}()
        .write()
        .register(arc{{ extra_args }})
    {
        Ok(_) => rustler::types::atom::Atom::from_str(env, "ok").unwrap(),
        Err(_) => rustler::types::atom::Atom::from_str(env, "error").unwrap(),
    }
}