Macro neon::register_module[][src]

macro_rules! register_module {
    ($module:pat, $init:block) => { ... };
}

Register the current crate as a Node module, providing startup logic for initializing the module object at runtime.

The first argument is a pattern bound to a neon::context::ModuleContext. This is usually bound to a mutable variable mut cx, which can then be used to pass to Neon APIs that require mutable access to an execution context.

Example:

This example is not tested
register_module!(mut cx, {
    cx.export_function("foo", foo)?;
    cx.export_function("bar", bar)?;
    cx.export_function("baz", baz)?;
    Ok(())
});