High level NodeJS N-API binding
napi-rs provides minimal overhead to write N-API modules in Rust.
Feature flags
napi1 ~ napi7
Because NodeJS N-API has versions. So there are feature flags to choose what version of N-API you want to build for.
For example, if you want build a library which can be used by node@10.17.0, you should choose the napi5 or lower.
The details of N-API versions and support matrix: n_api_version_matrix
tokio_rt
With tokio_rt feature, napi-rs provides a tokio runtime in an additional thread.
And you can easily run tokio future in it and return promise.
use *;
use ;
use tokio;
Tokio channel in napi-rs buffer size is default 100.
You can adjust it via NAPI_RS_TOKIO_CHANNEL_BUFFER_SIZE environment variable
NAPI_RS_TOKIO_CHANNEL_BUFFER_SIZE=1000 node ./app.js
latin1
Decode latin1 string from JavaScript using encoding_rs.
With this feature, you can use JsString.as_latin1_string function
serde-json
Enable Serialize/Deserialize data cross JavaScript Object and Rust struct.