Someone recently posted a pretty interesting question on Reddit so I thought I’d post it here as well to get the most answers.
Rust is already able to interoperate with other languages quite well by exposing/consuming a C interface, however other than a (fairly detailed) page in The Book there aren’t many resources available on integrating Rust into a multilingual project.
For example, if a company wanted to integrate a Rust module into its product, what kinds of things would it need to know? Are there any guides on doing this? Are there any best practices to know, and how do I handle errors ergonomically?
It would be really cool if there were a Rust FFI book in a similar vein to Learning Rust With Entirely Too Many Linked Lists that could walk you through an example from start to end and answer some of those questions, explaining the thought process going on behind the scenes.
Adding to the questions posed by the OP, what extra resources/documentation/tools are needed to help make it easy to use Rust alongside other projects? And how could I add to or update my FFI Guide to help address these issues?
I quite like the idea of stepping someone through the entire process of integrating a Rust module into a multilingual project from the very beginning, but can’t think of any non-trivial or contrived projects. Sadly I can’t use anything from work because of IP and copyright reasons.