Ask HN: Exposing C ABI from Rust library?
I have a project called XferLang (https://github.com/paulmooreparks/Xfer) that is a data-transfer language with a few features that I like (and use) which aren't found in JSON. Right now, it's implemented in C#, and my first idea for porting it to other languages was just to rewrite it in those languages. Now, my idea is to reimplement the core library (elements, parser, and serializer/deserializer) in Rust, expose a C-like ABI, and then wrap that with other languages. That way I'm only managing one core library. Since I'm still quite new to Rust, is this a technique used in any other significant projects? Is it viable? Should I expect to be able to call into the library from essentially any language the way I would be able to call into a C library?
Exposing a C ABI for a Rust library is perfectly viable and a nice way to make cross-language bindings.
cbindgen is the recommended crate to generate a C interface for your Rust library:
https://github.com/mozilla/cbindgen
Thank you!