Attribute Macro main
#[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.
If a main
function is not provided, all registered exports will be exported. If
the tokio
feature flag is enabled, a multithreaded tokio runtime will also be
registered globally.
#[neon::main]
fn main(mut cx: ModuleContext) -> NeonResult<()> {
// Export all registered exports
neon::registered().export(&mut cx)?;
let version = cx.string("1.0.0");
cx.export_value("version", version)?;
Ok(())
}