Generating ergonomic C++ APIs using Rustdoc, procedural macros, and Serde
summary
Claim: generate ergonomic C++ APIs from an existing Rust API by producing low‑level extern "C" functions that pass byte buffers and then auto‑produce high‑level C++ bindings. Tools actually used are procedural macros, rustdoc’s unstable JSON format, and Serde + bincode to (de)serialize arguments; generated C++ types and per‑impl files mirror Rust types. Measured serialization roundtrip is about 105 ns versus ~40–45 ns baseline, and the system runs in production for months; rustdoc JSON requires nightly.
AI-written summary · about
chapters (11)
- 0:00Introduction
- 1:25FFI matters for Rust
- 3:11Past C++ interop challenges
- 9:28Goals for new FFI
- 11:14Procedural macros for C API
- 15:28Parsing Rust with rustdoc
- 18:43Generating C++ types/functions
- 21:56Async functions in API
- 24:27Serialization performance
- 25:32Benefits and trade-offs
- 26:56Status and future plans
related talks
24mGenerating ergonomic C++ APIs using Rustdoc, procedural macros, and Serde
25mRust and C++
24mMacros for a More Productive Rust
29mMacromancy: an introduction to Rust macros
53mC++/Rust Interop: A Practical Guide to Bridging the Gap Between C++ and Rust
31mRustly typed APIs; ... JSON RPC with Rust, Procedural macros and a DSL
28mC2Rust: Migrating Legacy Code to Rust
31mFrom C++ APIs to Idiomatic Rust: Wrapper Design Patterns
