rustler/
nif.rs

1use crate::codegen_runtime::{c_char, c_int, c_uint, DEF_NIF_FUNC, NIF_ENV, NIF_TERM};
2
3pub struct Nif {
4    pub name: *const c_char,
5    pub arity: c_uint,
6    pub flags: c_uint,
7    // pub func: DEF_NIF_FUNC,
8    pub raw_func:
9        unsafe extern "C" fn(nif_env: NIF_ENV, argc: c_int, argv: *const NIF_TERM) -> NIF_TERM,
10}
11
12impl Nif {
13    pub fn get_def(&self) -> DEF_NIF_FUNC {
14        DEF_NIF_FUNC {
15            arity: self.arity,
16            flags: self.flags,
17            function: self.raw_func,
18            name: self.name,
19        }
20    }
21}
22
23unsafe impl Sync for Nif {}
24
25inventory::collect!(Nif);