async-ffi: FFI-compatible Future
s
Convert your Rust Future
s into a FFI-compatible struct without relying unstable Rust ABI and struct layout.
Easily provide async functions in dynamic library maybe compiled with different Rust than the invoker.
See documentation for more details.
Provide some async functions in library: (plugin side)
// Compile with `crate-type = ["cdylib"]`.
use ;
pub extern "C"
Execute async functions from external library: (host or executor side)
use ;
extern "C"
async
By default FfiFuture
requires the original Future
to be Send
.
In case of single-threaded runtime or target (like wasm32-none-none
), we may need to relax this requirement.
So we have LocalFfiFuture
, which is the almost the same as FfiFuture
but without Send
requirement.
// Compile with `crate-type = ["cdylib"]`, targeting `wasm32-none-none`.
use ;
pub extern "C"
abi-stable
suppport
If you want to use this crate with abi-stable
interfaces. You can enable the feature flag
abi_stable
(disabled by default), then the struct FfiFuture
and friends would derive
abi_stable::StableAbi
.
License
MIT Licensed.