![Latest Version] ![docs] ![MIT]
🦀 → 🐙 → Python, C#, C, ...
FFI bindings to your favorite language. Composable. Explicit. Escape hatches included.
If you ...
extern "C"
API in Rust... then Interoptopus might be for you.
Assume you have written this Rust FFI code:
```rust use interoptopus::{ffifunction, ffitype};
pub struct Vec3f32 { pub x: f32, pub y: f32, pub z: f32, }
pub extern "C" fn mygamefunction(input: Option<&Vec3f32>) -> Vec3f32 { Vec3f32 { x: 2.0, y: 4.0, z: 6.0 } }
interoptopus::inventoryfunction!(ffiinventory, [], [mygamefunction], []); ```
You can now use one of these backends to generate interop code:
| Language | Crate | Sample Output | Comment | | --- | --- | --- | --- | | C# (incl. Unity) | interoptopusbackendcsharp | Interop.cs | Built-in. | | C | interoptopusbackendc | myheader.h | Built-in.| | Python CFFI | interoptopusbackendcpythoncffi | reference.py | Built-in. | | Your language | Write your own backend! | - | See existing backends. |
See the reference project for a list of all supported features.
PRs are welcome.
Bug fixes can be submitted directly. Major changes should be filed as issues first.
Anything that would make previously working bindings change behavior or stop compiling is a major change; which doesn't mean we're opposed to breaking stuff before 1.0, just that we'd like to talk about it before it happens.
New features or patterns must be materialized in the reference project and accompanied by an interop test (i.e., a backend test running C# / Python against a DLL invoking that code) in at least one included backend.