Attribute Macro cxx::bridge

source ·
#[bridge]
Expand description

#[cxx::bridge] mod ffi { ... }

Refer to the crate-level documentation for the explanation of how this macro is intended to be used.

The only additional thing to note here is namespace support — if the types and functions on the extern "C++" side of our bridge are in a namespace, specify that namespace as an argument of the cxx::bridge attribute macro.

#[cxx::bridge(namespace = "mycompany::rust")]

The types and functions from the extern "Rust" side of the bridge will be placed into that same namespace in the generated C++ code.