A Rust Crate that also quacks like a modern C++ Library
summary
encoding_rs is the real example: its Rust API is mapped to a C ABI and an almost‑exact modern C++ surface used in Firefox 56, replacing the old 1999 library. Practical techniques include exposing Rust statics as C pointers, using gsl::span for slices, translating Box to std::unique_ptr and using operator delete routing to free with Rust's allocator, and avoiding vtables so C++ has no inheritance over Rust objects. Variant enums and Cow lifetimes require workarounds.
AI-written summary · about
chapters (8)
- 0:00Introduction and context
- 2:03Analyzing the Rust API
- 5:38Modernizing the C++ API
- 9:32Memory management and FFI
- 14:12Method calls and limitations
- 17:00Type mapping and containers
- 21:32Advanced API implementation
- 25:25Summary and conclusions
related talks
01h 11mDuck-Tape Chronicles - Rust C++ Interop
59mRust for C++ developers - What you need to know to get rolling with crates
01h 22mRust for the C++ Programmer
40mRust’s approach of getting things right
37mDuck-Tape Chronicles: Rust/C++ Interop
41mWe can have nice things
06mHow We Replace Common C and C++ Libraries
01h 14mRust: A Friendly Introduction
