#cbindgen #bindgen #wrapper #compatible #boxed #abi #c-abi

ffi_types

C ABI compatible wrappers for cbindgen/bindgen

17 releases

Uses new Rust 2024

0.0.19 Jan 7, 2026
0.0.17 Aug 25, 2025
0.0.16 Jul 28, 2025
0.0.13 Nov 4, 2024
0.0.5 Mar 8, 2024

#63 in FFI

Download history 621/week @ 2025-10-21 1044/week @ 2025-10-28 571/week @ 2025-11-04 984/week @ 2025-11-11 1101/week @ 2025-11-18 715/week @ 2025-11-25 1055/week @ 2025-12-02 811/week @ 2025-12-09 635/week @ 2025-12-16 473/week @ 2025-12-23 390/week @ 2025-12-30 1414/week @ 2026-01-06 907/week @ 2026-01-13 737/week @ 2026-01-20 380/week @ 2026-01-27 319/week @ 2026-02-03

2,822 downloads per month

BSD-2-Clause

34KB
909 lines

ffi_types

This repository provides C-ABI compatible basic Rust types including box, slice, str and boxed slice/str. By carefully following instructions, the types are bindgen/cbindgen compatible and owned values are safe under C++.

The project consists of 2 parts. A rust crate of #[repr(C)] wrappers of rust types and a header file for C++ (or a few more later).

The conversions are intended to be zero-cost.

TODO: link to docs and examples

CBindgen

Use ffi_types::cbindgen::with_cxx_ffi_types() to add proper configuration to cbindgen::Builder.

Bindgen

Block the provided header to blocklist_file. Replace all root::ffi_types:: to ffi_types:: in generated file.

Not the best choice for FFI

If you start a new project, please check cxx fits in your case.

Since the goal of ffi_types is exposing Rust type to C++ side, you need access to C++ code base.

ffi_types only provides types. Nothing is automatic. You still need to manage bindgen/cbindgen.

MSVC is very picky. ffi_types limits convenience initializers for C-prefixed types for MSVC. It will be less convenient and more unsafe.

Dependencies

~0.1–6MB
~132K SLoC