Crates.io | libnode_rs |
lib.rs | libnode_rs |
version | 0.0.2 |
created_at | 2025-04-12 11:14:49.935731+00 |
updated_at | 2025-04-12 11:16:53.610435+00 |
description | Library embedding Nodejs (libnode) within Rust |
homepage | |
repository | https://github.com/alshdavid/libnode |
max_upload_size | |
id | 1630822 |
size | 115,426 |
This repo contains patches to Nodejs to add a C API to libnode and a Rust crate that has bindings to embed Nodejs within a Rust application.
Using the libnode_rs
crate you can execute JavaScript directly in your Rust application
use libnode_rs;
pub fn main() -> std::io::Result<()> {
// Inject a native module into the JavaScript runtime
libnode_rs::napi_module_register("my_native_extension", |env, exports| {
// Modify and return the exports object
exports
});
// Execute JavaScript and access the native extensions via process._linkedBinding
libnode_rs::eval_blocking(r#"
const message: string = "Hello World TypeScript"
console.log(message)
console.log(process._linkedBinding("my_native_extension"))
"#)?;
Ok(())
}
# Linux
./scripts/build
# Windows
./scripts/build.ps1