Skip to content

ralfbiedert/interoptopus

Repository files navigation

crates.io-badge docs.rs-badge license-badge rust-version-badge rust-build-badge

Interoptopus 🐙

Productive, performant, robust interop for Rust. Pick three.

With Interoptopus you can write code like this:

#[ffi(service)]
pub struct Hello {}

#[ffi]
impl Hello {
    pub fn world() -> Result<Self, Error> { Ok(Self {}) }
}

and then call it from your other language like this:

var service = Hello.World();

Its key features include:

  • Nanosecond fast.
  • Supports structs, data-enums, callbacks, services, async, idiomatic error handling, and much more ...
  • Bidirectional interop, export your Rust library, or load foreign code into your Rust app.
  • Painless workflow, no external tooling required.
  • Polyglot core, first-class support for C#, can support any other language.

Getting Started

Read our documentation here.

Feature Flags

Gated behind feature flags, these enable:

  • macros - Proc macros such as #[ffi].
  • serde - Serde attributes on internal types.
  • tokio - Convenience support for async services via Tokio.
  • unstable-plugins - Experimental 'reverse interop' plugins. Not semver stable!

Supported Languages

Language Backend Crate Status
C# interoptopus_csharp
C interoptopus_c ⏯️
Python interoptopus_cpython ⏯️
Other Write your own backend1

Tier 1 target. Active maintenance and production use. Full support of all features.
⏯️ Tier 2 target. Currently suspended, contributors wanted!
1 You can implement basic support for a new language in just a few hours, no pull request needed.

Performance

In essence, plain calls are near-zero overhead (1-10ns), as are most structs, enums and services. If serialization is involved it scales with payload size. Using the .NET runtime as a plugin adds ~20 MB overhead.

For more details see our benchmark numbers here.

Further Reading

Contributing

PRs are very welcome!

  • Submit small bug fixes directly. Major changes should be issues first.
  • New features or patterns must be materialized in the reference project and accompanied by at least a C# interop test.

About

The polyglot bindings generator for your library (C#, C, Python, …) 🐙

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages