{"id":13432780,"url":"https://github.com/denoland/deno_bindgen","last_synced_at":"2025-05-16T13:03:26.186Z","repository":{"id":37011951,"uuid":"397514988","full_name":"denoland/deno_bindgen","owner":"denoland","description":"Write high-level Deno FFI libraries in Rust.","archived":false,"fork":false,"pushed_at":"2023-11-12T18:01:56.000Z","size":782,"stargazers_count":305,"open_issues_count":24,"forks_count":27,"subscribers_count":19,"default_branch":"main","last_synced_at":"2025-05-09T10:53:21.179Z","etag":null,"topics":["bindgen","deno","ffi","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/denoland.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2021-08-18T07:40:14.000Z","updated_at":"2025-05-08T18:04:59.000Z","dependencies_parsed_at":"2023-11-12T07:21:24.812Z","dependency_job_id":"bfb043c5-a0d4-4351-b8da-222e7b1f232b","html_url":"https://github.com/denoland/deno_bindgen","commit_stats":{"total_commits":98,"total_committers":15,"mean_commits":6.533333333333333,"dds":"0.22448979591836737","last_synced_commit":"ab6c49c7b44c7c1e238d1f1dc06981a57c1e0717"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denoland%2Fdeno_bindgen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denoland%2Fdeno_bindgen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denoland%2Fdeno_bindgen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denoland%2Fdeno_bindgen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/denoland","download_url":"https://codeload.github.com/denoland/deno_bindgen/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254535826,"owners_count":22087398,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bindgen","deno","ffi","rust"],"created_at":"2024-07-31T02:01:16.479Z","updated_at":"2025-05-16T13:03:26.163Z","avatar_url":"https://github.com/denoland.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"# `deno_bindgen`\n\n\u003cimg align=\"right\" src=\"./assets/illustration.png\" width=200\u003e\n\n[![ci](https://github.com/denoland/deno_bindgen/workflows/ci/badge.svg?branch=main)](https://github.com/denoland/deno_bindgen/actions)\n[![crates](https://img.shields.io/crates/v/deno_bindgen.svg)](https://crates.io/crates/deno_bindgen)\n[![docs](https://docs.rs/deno_bindgen/badge.svg)](https://docs.rs/deno_bindgen)\n\nThis tool aims to simplify glue code generation for Deno FFI libraries written\nin Rust.\n\n## Install\n\nInstall the command-line via `cargo`:\n\n```bash\ncargo install deno_bindgen_cli\n```\n\n## Usage\n\n```rust\nuse deno_bindgen::deno_bindgen;\n\n// Export `add` function to JavaScript.\n#[deno_bindgen]\nfn add(a: u32, b: u32) -\u003e u32 {\n    a + b\n}\n```\n\nUse the exported functions directly in ESM with TypeScript typings\n\n```typescript\nimport { add } from \"./bindings/mod.ts\";\n\nadd(1, 2);\n```\n\n## Design\n\nThe tool is designed to make it very easy to write high performance FFI\nbindings. A lot of the things have been redesigned in `0.10` to prevent perf\nfootguns.\n\nTypeScript types are generated and supported OOTB.\n\nAll class handles support disposing memory via the Explicit Resource Management\nAPI (`using`).\n\n```rust\n#[deno_bindgen]\npub struct Foo;\n\n#[deno_bindgen]\nimpl Foo {\n  #[constructor]\n  pub fn new() -\u003e Self {\n    Self\n  }\n\n  pub fn bar(\u0026self) {\n    // ...\n  }\n}\n```\n\n```js\nimport { Foo } from \"@ffi/example\";\n\n{\n  using foo = new Foo();\n  foo.bar();\n  // foo is disposed here...\n}\n```\n\nHigh performance. Codegen tries its best to take the fastest possible path for\nall bindings as-if they were written by hand to properly leverage the power of\nthe Deno FFI JIT calls.\n\n```\n\u003e make bench\ncpu: Apple M1\nruntime: deno 1.38.0 (aarch64-apple-darwin)\n\nfile:///Users/divy/gh/deno_bindgen/example/bench.js\nbenchmark      time (avg)        iter/s             (min … max)       p75       p99      p995\n--------------------------------------------------------------- -----------------------------\nadd             6.88 ns/iter 145,297,626.6    (6.78 ns … 13.33 ns)   6.81 ns   8.22 ns    9.4 ns\nbytelen         8.05 ns/iter 124,278,976.3     (7.81 ns … 18.1 ns)   8.09 ns  10.39 ns  11.64 ns\n```\n\n## Publishing\n\nBy default, deno_bindgen generates bindings for local development. To publish a\ncross-platform binding, you can use the `--lazy-init` flag, this gives you full\ncontrol on how you want to host pre-built shared libraries and pull them in at\nruntime.\n\n```bash\ndeno_bindgen --release --lazy-init\n```\n\n```typescript\nimport { add, load } from \"./example/mod.ts\";\nimport { cache } from \"https://deno.land/x/cache/mod.ts\";\n\n// Download the shared library from a CDN\nconst file = await cache(\"https://example.com/example.so\");\nload(file.path);\n\nadd(1, 2);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdenoland%2Fdeno_bindgen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdenoland%2Fdeno_bindgen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdenoland%2Fdeno_bindgen/lists"}