Crate ffi

source ·
Expand description

The ffi macro allows you to easily export FFI interfaces for your Rust code with minimal boilerplate. It is designed to facilitate several unique use cases which commonly occur in FFI code, particularly where a Rust shared library is dlopened by a C program and called into.

  • Callbacks from C to Rust code using opaque pointers to Rust objects
  • Callbacks in C code to Rust code where passing a closure is preferred to passing a function pointer, for example where state capture is desired.

Attribute Macros

  • Wrap an impl block with #[ffi(...)] to generate FFI functions for all methods in the impl block.