I’ve been using Rust for quite a while and have made several standalone tools in the past. However now I’m trying to integrate some Rust into a large legacy codebase at work by compiling to a DLL/ *.so and providing a C-style header file.

I’d like to hear people’s experiences doing something like this, and compile a small list of useful resources (if one doesn’t already exist) to help others use Rust as part of larger projects.

Some useful resources I’ve found so far:

Some interesting questions which may need to be solved:

Making sure your header file is kept in sync with the symbols your crate exports (I ended up making my own tool for this)

How do you provide good documentation for the exported bindings?

What pain points are there exposing Rust to C? (e.g. ensuring correctness and memory safety with unsafe FFI bindings, integrating into an existing build system, etc)

And just in general, if you’ve done something like this before, how did it go? If not, can you think of any issues (both technical and cultural) which I might encounter in the long term?