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.
libffi-rs: Rust bindings for libffi
The C libffi library provides two main facilities: assembling calls
to functions dynamically, and creating closures that can be called
as ordinary C functions. In Rust, the latter means that we can turn
a Rust lambda (or any object implementing Fn
/FnMut
) into an
ordinary C function pointer that we can pass as a callback to C.
The easiest way to use this library is via the high
layer module, but
more flexibility (and less checking) is provided by the middle
and
low
layers.
Usage
It’s on crates.io, so it can be
used by adding libffi
to the dependencies in your project’s
Cargo.toml
:
[]
= "0.1"
It is necessary to have C libffi installed first. (We’ve tested with libffi version 3.2.1.)
Example
In this example, we convert a Rust lambda containing a free variable
into an ordinary C code pointer. The type of fun
below is
extern "C" fn(u64, u64) -> u64
.
use Closure2;
let x = 5u64;
let f = ;
let closure = new;
let fun = closure.code_ptr;
assert_eq!;
Building
I’m writing this section to document my build process.
-
Installed pkg-config: brew install pkg-config
-
Installed libffi 3.2.1 (rather than OS X system libffi, which is old)
- brew install autoconf automake
-
Installed bindgen 0.18.0