🍝 edoN 🍜
Embed Node.js within Rust
Embed the fully featured Nodejs runtime into your Rust application!
Features:
- Bindings for
libnode - Native Nodejs extensions via napi-rs bindings
- Multi-threading support
- Evaluate arbitrary JavaScript
- Execute arbitrary n-api code
- Support for async Rust (Experimental, coming soon)
Use Cases
- Use JavaScript plugins with full support for Nodejs in your Rust application
- Roll your own multi-threaded lambda runtime
- Roll your own multi-threaded SSR implementation
- Avoid the need to embed your application within an n-api extension
Usage
Simple Example
Evaluate JavaScript as a string
Native Extensions
Register a Napi extension and use the napi-rs API to work with the values
Execute Native code in the Nodejs Context
Run native code against a specific Nodejs context. This is essentially eval but using
Node's n-api.
Libnode Shared Library
This requires the libnode shared library. Currently Node.js don't provide prebuilt binaries so you have to compile libnode yourself.
Offering prebuilt binaries with a C FFI is currently under development, however in the meantime you can download libnode from here:
https://github.com/alshdavid/libnode-prebuilt
|
Distributing libnode with your application
I haven't had success in compiling libnode to a static library so currently you must include the libnode dynamic library alongside your binary.
/your-app
your-app
libnode.so
You can instruct edon to automatically find libnode by using
Or manually specify the path
Credits
Project is inspired by and contains code from: