safer-ffi-banner

Introduction

safer_ffi is a rust framework to generate a foreign function interface (or FFI) easily and safely.

This framework is primarily used to annotate rust functions and types to generate C headers without polluting your rust code with unsafe.

It's inspired by #[wasm_bindgen]. It's mainly expose Rust to C over the FFI (allowing C code calling into Rust code). However, it does have some usages for C to Rust over the FFI (callbacks or extern { ... } headers).

This chart shows the comparison of traditional FFI types vs ones using safer_ffi.

Traditional FFIsafer_ffi
Mutable pointer or NULL*mut TOption<&mut T>
Mutable pointer*mut T&mut T
Owned pointer or NULL*mut TOption<repr_c::Box<T>>
Owned pointer*mut Trepr_c::Box<T>

Rust documentation

Link to the rustdoc-generated API documentation .

Prerequisites

  • Minimum Supported Rust Version: 1.60.0

Getting started

See the next chapter or the chapter on Detailed Usage.

Warning: safer_ffi is still in an alpha stage. Some features may be missing, while others may be changed when further improving it.