2 releases
new 0.1.1 | May 9, 2025 |
---|---|
0.1.0 | May 7, 2025 |
#218 in FFI
85 downloads per month
135KB
3.5K
SLoC
ferrosaur
ferrosaur derives statically-typed Rust code — à la wasm-bindgen — for
deno_core::JsRuntime
to interface with your JavaScript code.
You have:
// lib.js
export const add = (a, b) => a + b;
You write:
// lib.rs
#[js(module("lib.js"))]
struct Module;
#[js(interface)]
impl Module {
#[js(func)]
fn add(&self, a: serde<f64>, b: serde<f64>) -> serde<f64> {}
}
You get:
// let rt: &mut JsRuntime;
let module = Module::main_module_init(rt).await?;
let result = module.add(66.0, 3.0)?;
[!TIP]
This is like the inverse of
deno_core::op2
:
#[op2]
gives JavaScript programs easy access to your Rust implementation.- ferrosaur gives your Rust program easy access to JavaScript implementations.
License
This project is released under the Apache 2.0 License and the MIT License.
Dependencies
~0.6–1MB
~23K SLoC