Attribute Macro neon::main[][src]

#[main]
Expand description

Marks a function as the main entry point for initialization in a Neon module.

This attribute should only be used once in a module and will be called each time the module is initialized in a context.

#[neon::main]
fn main(mut cx: ModuleContext) -> NeonResult<()> {
    let version = cx.string("1.0.0");

    cx.export_value("version", version)?;

    Ok(())
}

If multiple functions are marked with #[neon::main], there may be a compile error:

error: symbol `napi_register_module_v1` is already defined