Skip to main content

set_custom_transport

Function set_custom_transport 

Source
pub unsafe fn set_custom_transport(
    ops: Option<NrosTransportOps>,
) -> Result<(), TransportError>
Expand description

Phase 115.A — register a custom transport vtable. Must be called before the first Rmw::open (or rclc_support_init from the C surface). v1 leaves enforcement of “before init” to backend code, and NO backend enforces it: a call after Rmw::open is implementation-defined, which is also what the C entry point rclc_set_custom_transport documents. This line used to say backends “reject re-registration with ALREADY_INIT” — rmw_ret.h defines no such code (issue 1126), so the sentence promised both a behaviour and a constant that do not exist.

Pass None to clear a previously-registered vtable (e.g. for teardown in tests).

Returns Err(TransportError::IncompatibleAbi) when ops.is_some() but abi_version != NROS_TRANSPORT_OPS_ABI_VERSION_V1. C / C++ wrappers map this to NROS_RMW_RET_INCOMPATIBLE_ABI.

§Safety

The four fn pointers in ops must follow the threading contract documented on NrosTransportOps — no concurrent read/write, no ISR invocation, user_data outlives the transport’s active period.