ffi_types 0.0.21

C ABI compatible wrappers for cbindgen/bindgen.
Documentation
const CXX_TYPE_NAMES: &[&str] = &[
    // array
    "Array",
    // simple box
    "Box",
    "OptionBox",
    // slices
    "SliceRef",
    "MutSliceRef",
    "BoxedSlice",
    "ByteSliceRef",
    "BoxedByteSlice",
    // strings
    "StrRef",
    "BoxedStr",
];
const CXX_WRAPPER_NAMES: &[&str] = &[
    // simple box
    "CBox",
    "COptionBox",
    // slices
    "CSliceRef",
    "CByteSliceRef",
    "CBoxedSlice",
    "CBoxedByteSlice",
    // strings
    "CStrRef",
    "CBoxedStr",
    "CharStrRef",
];

#[must_use]
pub fn with_cxx_ffi_types(builder: cbindgen::Builder) -> cbindgen::Builder {
    with_cxx_ffi_types_with_namespace(builder, "ffi_types")
}

#[must_use]
pub fn with_cxx_ffi_types_with_namespace(
    mut builder: cbindgen::Builder,
    namespace: &str,
) -> cbindgen::Builder {
    // builder = builder.with_sys_include("rust_types.h");
    for name in CXX_TYPE_NAMES {
        builder = builder.exclude_item(name);
        builder = builder.rename_item(name, &alloc::format!("{namespace}::{name}").as_str());
    }
    for name in CXX_WRAPPER_NAMES {
        builder = builder.exclude_item(name);
        builder = builder.rename_item(name, &alloc::format!("{namespace}::{name}").as_str());
    }

    builder
}