Publish Your Crate! - The bindgen User Guide (original) (raw)

  1. 1. Introduction
  2. 2. Requirements
  3. 3. Library Usage with build.rs
    1. 3.1. Tutorial
      1. 3.1.1. Add bindgen as a Build Dependency
        1. 3.1.2. Create a wrapper.h Header
        2. 3.1.3. Create a build.rs File
        3. 3.1.4. Include the Generated Bindings in src/lib.rs
        4. 3.1.5. Write a Sanity Test
        5. 3.1.6. Publish Your Crate!
    2. 3.2. Bindings for non-system libraries
  4. 4. Command Line Usage
  5. 5. Customizing the Generated Bindings
    1. 5.1. Allowlisting
    2. 5.2. Blocklisting
    3. 5.3. Treating a Type as an Opaque Blob of Bytes
    4. 5.4. Replacing One Type with Another
    5. 5.5. Preventing the Derivation of Copy and Clone
    6. 5.6. Preventing the Derivation of Debug
    7. 5.7. Preventing the Derivation of Default
    8. 5.8. Annotating types with #[must-use]
    9. 5.9. Field visibility
    10. 5.10. Code formatting
  6. 6. Generating Bindings to C++
  7. 7. Generating Bindings to Objective-c
  8. 8. Using Unions
  9. 9. Using Bitfields
  10. 10. Using Flexible Array Members
  11. 11. FAQ

The bindgen User Guide

Publish Your Crate!

That's it! Now we can publish our crate on crates.io and we can write a nice, Rust-y API wrapping the raw FFI bindings in a safe interface. However, there is already a bzip2-sys crate providing raw FFI bindings, and there is already a bzip2 crate providing a nice, safe, Rust-y API on top of the bindings, so we have nothing left to do here!

Check out the full code on Github!