Node.js N-API for Rust! [work in progress]
High-level N-API bindings for Node.js addons written in Rust.
Warning: this is a proof-of-concept implementation that's not intended for use yet. The project is under initial phase of development, the API is a quite sketchy and is going to be refactored heavily. If you are interested in contributing, though, it is super welcome!
The project is covered by a Code of Conduct.
Crates
napi-sys
: low-level bindings to N-API generated fromnode_api.h
usingbindgen
.napi
: high-level and rusty wrappers aroundnapi-sys
.napi-derive
: contains a procedural macro that allows to construct typesafe structures that represent N-API callback parameters and automatically validate the arguments that JavaScript code passes in.
Example
Check out https://github.com/aqrln/napi-rs/tree/master/example to see the full source code and project structure of this example. (TODO: initialize the module from Rust too).
lib.rs
extern crate napi;
extern crate napi_derive;
use ;
;
napi_callback!;
napi_callback!;
example.js
'use strict';
const addon = require;
addon.;
console.log;