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:
- @ag_dubs did an awesome talk at Rust Fest 2017 about how she got NPM to try out Rust
- The FFI Omnibus
- I experimented with writing a more in-depth FFI guide, however it needs a lot more work before it’s anywhere near as good as something like the Nomicon or Learning Rust With Entirely Too Many Linked Lists
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
unsafeFFI 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?