Skip to main content
Deno 2 is finally here 🎉️
Learn more

deno_bindgen

This tool aims to simplify glue code generation for Deno FFI libraries written in Rust.

QuickStart

deno install -Afq -n deno_bindgen https://deno.land/x/deno_bindgen/cli.ts
# Cargo.toml
[dependencies]
deno_bindgen = "0.2"
serde = { version = "1", features = ["derive"] }
// add.rs
use deno_bindgen::deno_bindgen;

#[deno_bindgen]
pub struct Input {
  a: i32,
  b: i32,
}

#[deno_bindgen]
fn add(input: Input) -> i32 {
  input.a + input.b
}
$ deno_bindgen
// add.ts
import { add } from "./bindings/bindings.ts";

add({ a: 1, b: 2 }); // 3

LICENSE

MIT