diplomat
The diplomat FFI generation macro
0.16.1
5.4M downloads/mo
#4380 most downloaded on crates.io
rust-diplomat/diplomat
What this package is like to depend on
Last release 3 days ago
20 Aug 2026
Ships fairly regularly
a new release about every 3 months
Rarely documented
notes for 3 of 21 stable releases
Nothing withdrawn
no release was ever pulled
5 years old
21 releases · first in 2021
5 releases in the last 12 months
see the full history below
Release timeline
21 releases · Feb 2021 to Aug 2026Releases
latest 21-
0.16.120 Aug 2026Release notes
Open source →Diplomat 0.16.1
Zulip Chat
Per discussion in #1235, we now have a dedicated Zulip chat for contributors, maintainers, and anyone curious about Diplomat: https://diplomat.zulipchat.com. Anyone interested in Diplomat is welcome, and no account is needed to browse the channels1.
Diplomat Runtime Semi-Stabilization
The Diplomat runtime is moving towards stabilization, so we're implementing a few changes in how we release the
diplomat-runtimecrate while we move towardsdiplomat-runtime 1.0.0.Our goal is to reduce churn for users using multiple diplomat crates in one build. Because
diplomat-runtimeexposesno_manglefunctions, you can only have one copy at a time linked in to a binary. Once we havediplomat-runtime 1.0.0we will not have these issues at all, but until then, we are going to limit the number of new0.x.0releases ofdiplomat-runtimewe make.Previously,
diplomat 0.x.0would always be accompanied bydiplomat-runtime 0.x.0to make it easy to match dependencies, since there is no formal dependency betweendiplomatanddiplomat-runtime. Now, when usingdiplomat 0.x.0, please use the latest0.y.zversion ofdiplomat-runtimewherey ≤ x. Once we releasediplomat-runtime 1.0.0, this will be simpler, just use1.0.Breaking API changes
Diplomat Tool
- For backends based on the C backend,
generating_struct_fieldshas been renamed togenerate_definition_includes, since this is now used for structs and traits (e75e064)
Other New Features
Dart
- Added
ErrorandExceptionto classes/enums which are used as errors and exceptions (#1220) (Contributed by mosuem and Robert Bastian) - Pinned Dart SDK to 3.12.2 (#1254)
.NET
- IDisposable is now opt-in (#1244) (Contributed by irvingoujAtDevolution and Copilot)
- Opaque wrappers now retain borrow dependencies (#1251) (Contributed by irvingoujAtDevolution and Copilot)
C++
- Added traits support (this is a preview feature, not recommended for use in production) (#1234)
Bug Fixes
Javascript
- Added validation to arguments to assure type correctness (#902) (Contributed by Robert Bastian)
.NET
- Now disposes borrowed edges of spans on oversized spans (#1253) (Contributed by irvingoujAtDevolution and Copilot)
The Book
Misc
- Updated Clippy MSRV to 1.88 (#1249)
- Wrote CONTRIBUTING.md document
-
You will have to make an account to chat, however. ↩
- For backends based on the C backend,
-
0.16.031 Jul 2026Release notes
Open source →Diplomat 0.16.0
synv3We've upgraded to
synv3 to stay up to date with newer minor releases ofsyn(#1228).NET backend
Diplomat used to have a .NET backend with the old AST representation. This was removed since we transitioned to the HIR representation, and existing users have been on an old fork of the AST-based backend. Thankfully, first-time contributor irvingoujAtDevolution has been hard at work implementing the new HIR-based .NET backend:
#1164 (co-authored with Claude Code), #1180, #1186, #1191, #1189, #1194, #1195, #1193 (co-authored with Claude Sonnet 4.6), #1201, #1216, #1214, #1213, #1215, #1226, #1225, #1230, #1231
File/Line information in AST Errors
Diplomat Core's MSRV is now 1.88, which enables support for procedural macro locations, which are used in new AST error reports. These new reports highlight line/file information instead of panicking with minimal context. There's a pretty printer that uses annotate-snippets (enabled by default in the tool, enabled elsewhere with the feature flag "pretty-print"), and an ugly printer (uses no extra dependencies, enabled by default in the macro).
This was accomplished in two steps: first, we added
proc_macro2::Spaninformation to AST. Subsequently, we made five PRs to replace existingpanic!,.expect, andassert!calls in the AST parser with these more detailed reports:#1172, #1177, #1183, #1206, #1208
Other New Features
Diplomat Core
- Added
#[diplomat::include]for including macro definitions from other files (#917) - Added support for partial comparisons (#1103)
- Added support for tuplable structs (#1101)
- Added Opaque slice support (#1088)
Diplomat Runtime
- Added no_std support for wasm32-unknown-unknown targets (First-time contribution by Brennan Kinney)
C++
Nanobind
- Expanded default arguments support to Nanobind
- Added support for docstrings and stubgen (First-time contribution by twantonie)
Dart
- Added support for null-aware Dart syntax
- Updated backend to use RecordUse syntax (Contributed by mosuem)
Bugfixes
Diplomat Macro
Diplomat Tool
JS Backend
- JS now does not generate mutable slices (which it does not support)
- diplomat_runtime's JS implementation now uses updated WASM target linkage
- JS now calls enum constructors from within struct fields
C++ Backend
- diplomat_runtime.hpp now compiles with Solaris (First-time contribution by Makoto Kato)
- Fixed struct references failing to compile with non-unit types
- Struct references now compile with references of opaques
- UTF-16 string slices now generate correctly (Contributed by Mark Molinaro, Manish Goregaokar and Claude Opus 4.6)
- Callbacks now accept unique_ptr
- Fixed Result<Option, Err> generation
- Fixed function pointer assignment mismatch on embedded toolchains (First-time contribution by obsking2000)
- Fixed returning references of opaques in callbacks
Nanobind Backend
- Fixed overloaded named constructors failing to build in Nanobind (First-time contribution by Mark Molinaro and AI tools)
- Fixed compiler error on fallible structure constructors that return opaques
- Nanobind backend now always defines struct references as mutable
- Enforce
IndexErrorable indexing operations - Fixed check that bound vector exists in memory
- Fixed overloading issue for const methods and empty arguments
- Fixed include generation info for callbacks
- Fixed stub type for
diplomat::result(Contributed by Mark Molinaro and Claude Opus 4.6) - Fixed compiler issue with string_view_for_slice not generating properly in overrides
- Fixed bound vectors with partial comparisons not compiling
- Properly generate out structs
- Fixed taking opaque references in callbacks
- Fixed lifetime annotations absent on read only properties (First-time contribution by Yazan-Reactor and Claude Fable 5)
Dart Backend
- Made DiplomatFfiUse final
- Agent Driven: Fixed fallible struct constructor compilation
- Agent Driven: Fixed Dart structs borrowing opaques
The Book
- C++ and Nanobind now have typing information and how types connect to the C ABI.
- Improved book organization and links within
- Added documentation on async Nanobind and workarounds
- Added documentation for the new .NET backend (Contributed by irvingoujAtDevolution)
Misc
- Added
-
0.15.031 Mar 2026 -
0.14.027 Oct 2025Nothing published for this version
-
0.13.023 Sep 2025Nothing published for this version
-
0.12.019 May 2025Nothing published for this version
-
0.11.006 May 2025Nothing published for this version
-
0.10.025 Feb 2025Nothing published for this version
-
0.9.023 Nov 2024Nothing published for this version
-
0.8.024 May 2024Nothing published for this version
-
0.7.015 Nov 2023Nothing published for this version
-
0.6.021 Sep 2023Nothing published for this version
-
0.5.228 Apr 2023Nothing published for this version
-
0.5.113 Apr 2023Nothing published for this version
-
0.5.017 Jan 2023Nothing published for this version
-
0.4.228 Oct 2022Nothing published for this version
-
0.4.120 Oct 2022Nothing published for this version
-
0.4.026 Sep 2022Nothing published for this version
-
0.3.029 Apr 2022Nothing published for this version
-
0.2.002 Aug 2021Nothing published for this version
-
0.1.022 Feb 2021Nothing published for this version