Vendored version of diplomat from crates.io
  • Rust 79.5%
  • Jinja 10%
  • Kotlin 3.2%
  • JavaScript 2.5%
  • C++ 1.8%
  • Other 2.9%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Reynard User 8b29b2901a
Some checks failed
Diplomat CI / build-test (push) Has been cancelled
Diplomat CI / msrv (push) Has been cancelled
Diplomat CI / gen (push) Has been cancelled
Diplomat CI / test-c (push) Has been cancelled
build / deploy_book (push) Has been cancelled
Diplomat CI / fmt (push) Has been cancelled
Diplomat CI / lint (push) Has been cancelled
Diplomat CI / check-c (macos-latest) (push) Has been cancelled
Diplomat CI / check-c (ubuntu-latest) (push) Has been cancelled
Diplomat CI / check-c (windows-latest) (push) Has been cancelled
Diplomat CI / test-cpp (push) Has been cancelled
Diplomat CI / check-cpp (macos-latest) (push) Has been cancelled
Diplomat CI / check-cpp (ubuntu-latest) (push) Has been cancelled
Diplomat CI / check-cpp (windows-latest) (push) Has been cancelled
Diplomat CI / test-js (18.20.3) (push) Has been cancelled
Diplomat CI / test-js (20.14.0) (push) Has been cancelled
Diplomat CI / test-js (22.3.0) (push) Has been cancelled
Diplomat CI / test-demo (18.20.3) (push) Has been cancelled
Diplomat CI / test-demo (20.14.0) (push) Has been cancelled
Diplomat CI / test-demo (22.3.0) (push) Has been cancelled
Diplomat CI / test-dart (push) Has been cancelled
Diplomat CI / test-kotlin (push) Has been cancelled
Diplomat CI / test-nanobind (push) Has been cancelled
Update pulldown-cmark dependency to use git.sly.so version
2026-05-11 11:01:07 +02:00
.github/workflows Support renames in Kotlin (#1069) 2026-03-05 10:16:56 -08:00
book Tuples Support (#1106) 2026-05-06 16:23:55 -07:00
core Nanobind Disable List Optional Comparisons for Bound Vectors (#1149) 2026-05-08 18:41:18 -07:00
docs Tweak Diplomat Docs (#855) 2025-04-14 16:55:21 -07:00
example C++ callback support for unique_ptr (#1138) 2026-05-04 10:11:04 -07:00
feature_tests Nanobind Disable List Optional Comparisons for Bound Vectors (#1149) 2026-05-08 18:41:18 -07:00
macro Partial comparison support (#1131) 2026-04-29 16:30:11 -07:00
runtime Partial comparison support (#1131) 2026-04-29 16:30:11 -07:00
support Implement lib-name support for C++ (#956) 2025-09-18 14:08:27 -07:00
tool Update pulldown-cmark dependency to use git.sly.so version 2026-05-11 11:01:07 +02:00
.gitattributes Nanobind reference leak fix (#912) 2025-07-13 20:37:08 -07:00
.gitignore Add maven build for Kotlin (#991) 2025-11-11 14:23:57 -08:00
Cargo.lock Fix wasm for Rust Nightly, publish runtime v0.15.1 (#1099) 2026-04-08 12:20:00 -07:00
Cargo.toml Update Diplomat to 0.15.0 (#1095) 2026-03-31 09:29:19 -07:00
clippy.toml Uprev MSRV to 1.81.0 (#821) 2025-03-25 02:07:26 +00:00
ContributingOnWindows.md Quick Windows Documentation Patch (#745) 2024-12-08 21:22:04 +00:00
LICENSE Update the license to match my intent. 2021-06-15 14:34:43 -07:00
Makefile.toml Add support for overriding dylib name in Kotlin (#997) 2025-11-20 12:08:41 -08:00
README.md We haven't been experimental for ages 2026-01-15 09:08:32 -05:00

Diplomat

Diplomat is a Rust tool for generating FFI definitions allowing many other languages to call Rust code. With Diplomat, you can simply define Rust APIs to be exposed over FFI and get high-level C, C++, and JavaScript bindings automatically!

Diplomat supports generating bindings from Rust to:

  • C
  • C++
  • Dart
  • Javascript/Typescript
  • Kotlin (using JNA)
  • Python (using nanobind)

Diplomat supports languages through a plugin interface that makes it easy to add support for your favourite language. See the book to get started, and tool/src/{c, cpp, js} for examples of existing language plugins.

Installation

First, install the CLI tool for generating bindings:

$ cargo install diplomat-tool

Then, add the Diplomat macro and runtime as dependencies to your project:

diplomat = "0.10.0"
diplomat-runtime = "0.10.0"

Getting Started

Documentation on how to use Diplomat can be found in the book.

Architecture

See the design doc for more details.

Building and Testing

Simply run cargo build to build all the libraries and compile an example. To run unit tests, run cargo test.

Diplomat makes use of snapshot tests to check macro and code generation logic. When code generation logic changes and the snapshots need to be updated, run cargo insta review (run cargo install cargo-insta to get the tool) to view the changes and update the snapshots.

Javascript bindings for wasm32-unknown-unknown

The Javascript backend assumes that you are building WebAssembly on the C Spec ABI. This is not currently default for the wasm32-unknown-unknown target in the latest version of Rust, and so until the new WASM ABI is made stable, you have two options:

  1. Build using nightly Rust and enable the -Zwasm-c-abi=spec flag.
  2. Configure the JS backend to use legacy bindings. There is a WASM ABI config option for this, please read the guide on configuration in the book for more on how to configure.