liveBook · Manning

Rust bindgen

rust bindgen is a code-generation tool that generates Rust foreign-function interface bindings from C and C++ declarations.

How 2 Manning books explain it

Refactoring to Rust

bindgen is a code-generation tool that creates language bindings from C and C++ declarations for use from Rust.

How it is used
Generates Rust bindings for an NGINX C API as part of an incremental Rust integration.
How deep it goes
Works through header setup, build-script configuration, output inclusion, filtering, and generated bitfield accessors.
Examples
Uses NGINX headers, an ngx_-filtered binding file, and response-buffer bitfield setters.
What you can do after
Apply it via bindgen to generate and include selected C API bindings in a Rust project.

Read how Refactoring to Rust explains rust bindgen →

Embedded Software with Rust

bindgen is a tool that generates Rust foreign-function interface declarations from C and C++ headers.

How it is used
Generates Rust FFI declarations from C headers for embedded integration with existing C libraries.
How deep it goes
Walks through command-line generation, filtering, target configuration, build-script automation, linking, inclusion, and an unsafe call.
Examples
Uses a hardware abstraction header with a struct and pointer-taking function, plus generated bindings and a call.
What you can do after
Apply it via bindgen to generate target-specific Rust declarations and include them in a Cargo project.

Read how Embedded Software with Rust explains rust bindgen →

Also covered in

What to know first

Related concepts

Questions about rust bindgen

What is rust bindgen?

rust bindgen is a code-generation tool that generates Rust foreign-function interface bindings from C and C++ declarations.

Which Manning books explain rust bindgen?

Refactoring to Rust and Embedded Software with Rust.

What should I know before learning rust bindgen?

Manning books that teach rust bindgen usually introduce Rust first.

What is the difference between rust bindgen and cbindgen?

rust bindgen is a code-generation tool that generates Rust foreign-function interface bindings from C and C++ declarations. cbindgen is a tool that generates C and C++ header files from Rust source code.

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.