note
This page is included only for link validation during build.
ferrosaur
So you use deno_core
, and you want to call JavaScript from Rust.
// If you have: lib.js
export const slowFib = (n) =>
n === 0 ? 0 : n === 1 ? 1 : slowFib(n - 1) + slowFib(n - 2);
// and you write: lib.rs
use ferrosaur::js;
#[js(module("lib.js"))]
struct Math;
#[js(interface)]
impl Math {
#[js(func)]
fn slow_fib(&self, n: serde<usize>) -> serde<usize> {}
}
// Then you get:
// let rt: &mut JsRuntime;
let lib = Math::main_module_init(rt).await?;
let fib = lib.slow_fib(42, rt)?;
assert_eq!(fib, 267914296);
ferrosaur derives types and implementations, à la wasm-bindgen, that you can use
with your favorite JsRuntime
.
Documentation
You may be looking for:
- Examples
- Reference
js(global_this)
|js(module)
|js(value)
|js(interface)
|js(prop)
|js(func)
|js(new)
License
This project is released under the Apache 2.0 License and the MIT License.