wrapgen 0.2.0

A tool to automatically generate safe wrappers around FFI functions
Documentation
  • Coverage
  • 68.75%
    11 out of 16 items documented3 out of 11 items with examples
  • Size
  • Source code size: 20.35 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.21 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 21s Average build duration of successful builds.
  • all releases: 21s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • ctiedt/wrapgen
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • ctiedt

wrapgen

Crates.io Crates.io

wrapgen is a tool to automatically generate Rust wrappers around C functions called via FFI. It will wrap pointer returns in an Option and int returns in a Result. As of now, wrapgen only works if your functions adhere to the C convention of returning 0 on a successful run and another value otherwise.

How to use wrapgen

You can use wrapgen as a standalone binary:

wrapgen input.rs output.rs

where input.rs contains one function declaration per line

or include it in your build.rs file:

fn main() {
    WrapGen::new("input1.rs")
        .add_file("input2.rs")
        .function("fn my_test_fn(arg1: cty::c_int) -> cty::c_int")
        .prefix("rs_")
        .use_core(false)
        .generate("output.rs");
}