Abstract
Rust provides a seamless way to consume and provide a C-compatible ABI.
We'll explore the tools available and the best practices to convert C libraries to Rust and expose back a C-API matching the original.
We'll see what are the current limitations and if there are ways to overcome them.
Rust and its ecosystem is maturing and lots of software is now proving that is possible to have implementations that are faster and safer than their C/C++/Python counterparts.
Lots of valid software still exists in other languages though, and providing easy ways to use the high performance Rust crates gets the best of both words.
During this tutorial we'll focus on C and see what tools and methods are available to:
- Build foreign code in Cargo;
- Generate bindings from C headers;
- Automatically convert C code in Rust;
- Generate C headers from a Rust C-API;
- Produce C libraries and related helpers (e.g. matching pkg-config files).
We'll see how some crates use those tools and try them out with simpler and more complex examples. As bonus track we'll see how generating bindings for C, wasm/Javascript and Python differ in ergonomics and philosophy.