Expand description
Phase 115.L.0 — Generic Rust-trait → C-vtable adapter.
RustBackendAdapter<R> converts any R: nros_rmw::Rmw whose
associated types implement the matching Session / Publisher /
Subscription / ServiceTrait / ClientTrait traits
into a static NrosRmwVtable. Each per-backend cffi crate then
collapses to ~10 LOC:
#[unsafe(no_mangle)]
pub extern "C" fn nros_rmw_zenoh_register() -> nros_rmw_cffi::NrosRmwRet {
nros_rmw_cffi::RustBackendAdapter::<nros_rmw_zenoh::ZenohRmw>::register()
}§Storage discipline
- Session:
Box::into_raw(Box::new(session))is stashed inNrosRmwSession::backend_data.closereclaims viaBox::from_raw(drops the box, runsDrop, frees the alloc). - Publisher / Subscription / Service / Client: same pattern with their respective handle types.
§’static
Every handle must be 'static (the Box outlives the call). We
deliberately do not require Send: the C runtime hands the
backend_data pointer back to the same caller that minted it,
and the executor’s single-thread-per-session invariant matches
the Rust trait surface. Zenoh-pico’s ZenohSession, for
instance, holds an unmovable *const Context which the
upstream library does not mark Send.
§Bounds
All error types must be TransportError (or Into<TransportError>).
This matches every in-tree backend today.
Structs§
- Rust
Backend Adapter - Wraps a Rust
Rmwbackend behind the canonicalNrosRmwVtableC ABI. See module docs.
Traits§
- Rust
Backend - Bundle of trait bounds an
Rmwbackend must satisfy to be exposed throughRustBackendAdapter. Implemented automatically for anyR: Rmwwhose handle types useTransportErrorand are'static.