![Latest Version] ![docs] ![MIT]

Interoptopus

🦀 → 🐙 → Python, C#, C, ...

FFI bindings to your favorite language. Composable. Sane. Escape hatches included.

Overview

If you ...

... then Interoptopus might be for you.

Known limitations

Supported Languages & Example

Assume you have written this Rust FFI code:

```rust use interoptopus::{ffifunction, ffitype};

[ffi_type]

[repr(C)]

pub struct Vec3f32 { pub x: f32, pub y: f32, pub z: f32, }

[ffi_function]

[no_mangle]

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 | Comment | | --- | --- | --- | | C# (incl. Unity) | interoptopusbackendcsharp | Built-in. | | C | interoptopusbackendc | Built-in. | | Python CFFI | interoptopusbackendcpython_cffi | Built-in. | | Your language | Write your own backend! | See existing backends for what to do. |

Current Status

Safety, Soundness, Undefined Behavior

This library naturally does "unsafe" things and any journey into FFI-land is a little adventure. That said, here are some assumptions and quality standards this project is based on:

FAQ

Contributing

PRs are welcome.

License

MIT

This license only applies to code in this repository, not code generated by this repository. We do not claim copyright for code produced by backends included here; even if said code was based on a template in this repository. For the avoidance of doubt, anything produced by Interop::write_to or any item emitted by a proc macro is considered "generated by".