async-ffi

Convert Rust Futures into FFI-compatible structs that cross ABI and dynamic-library boundaries

Library
Cargo
v0.5.1
185stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
52/100Fair
Development Activity48
Maintenance32
Community48
Maturity60
Momentum20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
80/100Excellent
Architecture86
Code Quality82
Innovation84
Learning Curve68

async-ffi is a Rust crate that wraps your Future types into an FFI-compatible struct with a stable, well-defined layout, so async code can cross the boundary between separately compiled Rust binaries or between Rust and C without relying on the unstable Rust ABI. This makes it possible to expose async functions from a dynamic library that may have been built with a different Rust compiler than the caller.

By defining an explicit polling ABI rather than depending on internal Future representation, async-ffi lets plugin systems and dynamically linked components share futures safely. It ships an optional macros helper and abi_stable integration, and is MIT licensed.

What You Get

  • An FFI-safe wrapper struct for Rust Futures with a stable memory layout
  • A polling ABI that works across separately compiled Rust binaries
  • Support for exposing async functions from dynamic libraries and plugins
  • Optional async-ffi-macros helpers for ergonomic conversions
  • Optional integration with the abi_stable crate

Common Use Cases

  • Exposing async functions from a Rust dynamic library or plugin
  • Driving a future produced by one Rust module from an executor in another
  • Interoperating async code between Rust and C via a stable ABI
  • Building plugin systems where host and plugin are compiled independently

Under The Hood

Architecture - The core lives in a single src/lib.rs that defines FFI-safe future wrapper types (such as FfiFuture) and a polling ABI implemented via C-compatible function pointers and a stable struct layout, so a future’s poll can be invoked across a module boundary without knowledge of the concrete type. A companion macros crate provides derive/attribute conveniences, and optional abi_stable support hardens layout guarantees. Tech Stack - Pure Rust with a deliberately tiny dependency surface: no required runtime dependencies, an optional abi_stable dependency, and the local async-ffi-macros proc-macro crate; dev-dependencies use tokio to exercise real async executors. Some C and a Makefile support cross-linking tests. Code Quality - The repo includes integration tests (tests/basic.rs), macro tests, and a link_tests workspace with executor/plugin pairs in both Rust and C that verify cross-linking end to end, plus a CHANGELOG and CI. API Design - The public API centers on converting an existing Future into an FfiFuture and awaiting the wrapper on the other side, keeping the ergonomic async/await model intact while hiding the unsafe ABI plumbing behind a small surface.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search