All Projects β†’ napi-rs β†’ Napi

napi-rs / Napi

Licence: mit
High-level Node.js N-API bindings for Rust [WIP] βœ¨πŸ¦€πŸš€βœ¨

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to Napi

V8pp
Bind C++ functions and classes into V8 JavaScript engine
Stars: ✭ 643 (+656.47%)
Mutual labels:  addons
Addon Manager
Manage addons in a Kubernetes cluster
Stars: ✭ 51 (-40%)
Mutual labels:  addons
Addon Wireguard
WireGuard - Home Assistant Community Add-ons
Stars: ✭ 72 (-15.29%)
Mutual labels:  addons
Rust Rocksdb
rust wrapper for rocksdb
Stars: ✭ 815 (+858.82%)
Mutual labels:  rust-bindings
Squashed Merge Message
Use Pull Request description as Squashed and Merged commit messages.
Stars: ✭ 34 (-60%)
Mutual labels:  addons
Addon Zwave2mqtt
Z-Wave to MQTT - Home Assistant Community Add-ons
Stars: ✭ 58 (-31.76%)
Mutual labels:  addons
Ramda Adjunct
Ramda Adjunct is the most popular and most comprehensive set of functional utilities for use with Ramda, providing a variety of useful, well tested functions with excellent documentation.
Stars: ✭ 550 (+547.06%)
Mutual labels:  addons
Lodepng Rust
All-in-one PNG image encoder/decoder in pure Rust
Stars: ✭ 78 (-8.24%)
Mutual labels:  rust-bindings
Repository Edge
EDGE - Home Assistant Community Add-ons
Stars: ✭ 42 (-50.59%)
Mutual labels:  addons
Addon Ide
IDE - Home Assistant Community Add-ons
Stars: ✭ 61 (-28.24%)
Mutual labels:  addons
Stripe Rs
Moved to https://github.com/wyyerd/stripe-rs.
Stars: ✭ 16 (-81.18%)
Mutual labels:  rust-bindings
Playwright Addons
Add-ons for Playwright: adblocker, stealth mode
Stars: ✭ 32 (-62.35%)
Mutual labels:  addons
Addon Adb
Android Debug Bridge - Home Assistant Community Add-ons
Stars: ✭ 58 (-31.76%)
Mutual labels:  addons
Ritual
Use C++ libraries from Rust
Stars: ✭ 792 (+831.76%)
Mutual labels:  rust-bindings
Gutenberg Parser Rs
An experimental Rust parser for WordPress Gutenberg post format
Stars: ✭ 76 (-10.59%)
Mutual labels:  rust-bindings
Minecraftdeveloperguide
πŸ“Minecraft developer Chinese guideοΌŒζˆ‘ηš„δΈ–η•ŒεΌ€ε‘θ€…δΈ­ζ–‡ζŒ‡ε—
Stars: ✭ 574 (+575.29%)
Mutual labels:  addons
Nestjs Dialogflow
Dialog flow module that simplify the web hook handling for your NLP application using NestJS πŸ“‘
Stars: ✭ 51 (-40%)
Mutual labels:  addons
Rust Onig
Rust bindings for the Oniguruma regex library
Stars: ✭ 81 (-4.71%)
Mutual labels:  rust-bindings
Rusted Switch
Nintendo Switch Homebrew with Rust πŸ¦€
Stars: ✭ 75 (-11.76%)
Mutual labels:  rust-bindings
Addon Spotify Connect
Spotify Connect - Home Assistant Community Add-ons
Stars: ✭ 60 (-29.41%)
Mutual labels:  addons

Node.js N-API for Rust! [work in progress]

Travis Build Status AppVeyor Build Status

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 from node_api.h using bindgen.
  • napi: high-level and rusty wrappers around napi-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 the example directory to see the full source code and project structure of this example. (TODO: initialize the module from Rust too).

lib.rs

#[macro_use]
extern crate napi;
#[macro_use]
extern crate napi_derive;

use napi::{NapiEnv, NapiNumber, NapiResult, NapiUndefined};

#[derive(NapiArgs)]
struct HelloArgs;

fn hello<'a>(env: &'a NapiEnv, _: &HelloArgs) -> NapiResult<NapiUndefined<'a>> {
    println!("Hello from the Rust land!");
    NapiUndefined::new(env)
}

#[derive(NapiArgs)]
struct AddArgs<'a> {
    first: NapiNumber<'a>,
    second: NapiNumber<'a>,
}

fn add<'a>(env: &'a NapiEnv, args: &AddArgs<'a>) -> NapiResult<NapiNumber<'a>> {
    let first = args.first.to_i32()?;
    let second = args.second.to_i32()?;
    NapiNumber::from_i32(env, first + second)
}

napi_callback!(example_hello, hello);
napi_callback!(example_add, add);

example.js

'use strict';

const addon = require('./build/Release/example.node');

addon.hello();
console.log(addon.add(1, 2));
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].