Skip to main content

pad_publisher_gid

Function pad_publisher_gid 

Source
pub const fn pad_publisher_gid<const N: usize>(narrow: &[u8; N]) -> [u8; 24]
Expand description

Zero-extend a backend’s narrower identity into a full-width publisher GID.

A backend whose identity is shorter than PUBLISHER_GID_SIZE must pad the TAIL with zeros rather than leave it undefined, or two gids naming the same publisher compare unequal on stack garbage. This is the one spelling of that padding on the Rust side; the Cyclone backend does the same thing in C++ (cyclone_get_gid_for_publisher in packages/rmw/cyclonedds/nros-rmw-cyclonedds/src/vtable.cpp — a memset, then a memcpy of the 16-byte DDS writer GUID).

An N wider than PUBLISHER_GID_SIZE is a compile error, which is the Rust spelling of Cyclone’s static_assert(sizeof(guid.v) <= RMW_GID_STORAGE_SIZE).