docs.rs failed to build ezffi-0.1.1
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
ezffi
Generate idiomatic C-FFI bindings from Rust types and functions with a single attribute, without having to worry about whether your types use C-compatible fields or not.
Pair it with cbindgen and you get:
typedef struct MyCrateCar MyCrateCar;
MyCrateCar ;
void ;
uint64_t ;
Ideas
- One attribute.
#[ezffi::export]on structs, enums,implblocks emits the C wrappers, the type definitions, and thefreefunction. No#[repr(C)]needed. - Picks the layout for you. Types whose fields are all C-compatible cross the boundary as
#[repr(C)]values; everything else goes behind an opaque pointer struct. The macro reads the source, no annotations —ezffialways makes the right decision. - Honest C signatures.
&self→const T*,&mut self→T*, ownedT→Tby value. The C side actually reflects which calls mutate (with a few exceptions for performance reasons). - Built-ins ship with their own headers.
Option,Result,String, and (withstd)Vec,HashMap,Arc,BTreeMap, etc., come pre-wrapped, each in its ownezffi/…h, so the consumer#includes only what they touch. This lets you export almost any function you write in Rust without having to worry about type compatibility. - Cross-crate aware. A crate can take a type another
ezfficrate exports and the macro resolves it without re-declaration.
Quick start and Documentation
📖 The ezffi Book contains all the information you need to set up and use this crate. It also explains how ezffi works internally and how to correctly use all the features it ships. It'll definitely help you decide if this crate is the right tool for your work.
Right now the book tracks the master branch only, I'll eventually set up per-version hosting so users can read the docs that match their installed version.
For examples, look at the crates under ffi-c-tests/, I'll be adding proper example files that are more readable than the test ones.
Features
std— bundles wrappers forVec,HashMap,BTreeMap,HashSet,BTreeSet,Arc,Rc,VecDeque. Off by default. I'll keep adding more if I see it's needed so users can#[ezffi::export]everything they need. See the book for more.async— lets you export async functions and plug in your own async dispatcher, see the book for more.