Expand description
C function table adapter for nros RMW backends.
This crate provides a vtable-based bridge so that backends written in C,
C++, Zig, Ada, or any language with a C-compatible ABI can implement the
nros Session / Publisher / Subscription / service traits without
writing Rust code.
§Usage (C backend implementor)
- Include
<nros/rmw_vtable.h> - Implement all function pointers in
nros_rmw_vtable_t - Call
nros_rmw_cffi_register(&my_vtable)before creating sessions
§Usage (Rust consumer)
Enable the rmw-cffi feature on nros and use Executor<CffiSession>.
Re-exports§
pub use rust_adapter::RustBackend;pub use rust_adapter::RustBackendAdapter;pub use generated::*;
Modules§
- generated
- AUTO-GENERATED by scripts/gen-abi-bindings.sh (bindgen 0.72.1) — DO NOT EDIT.
- rust_
adapter - Phase 115.L.0 — Generic Rust-trait → C-vtable adapter.
- section
- RMW backend self-registration (Phase 249 P4b.1 —
.init_arrayctor).
Macros§
- nros_
rmw_ register_ backend - Macro emitted by backend crates to self-register their vtable.
Structs§
- Cffi
Client - Service client backed by a C vtable.
- Cffi
Publisher - Publisher backed by a C vtable.
- CffiRmw
- RMW factory for the C function table backend.
- Cffi
Service - Service server backed by a C vtable.
- Cffi
Session - Session backed by a C vtable.
- Cffi
Subscription - Subscription backed by a C vtable.
Enums§
- Backend
Resolution - Phase 128.A.3 — outcome of
resolve_backend.
Constants§
- EMPTY_
VTABLE - A vtable with every slot NULL — the base for struct-update syntax.
- MAX_
BACKENDS - Compile-time max number of concurrently registered backends.
Set via
NROS_RMW_MAX_BACKENDSenv var at build time (build.rs). Default 8. - MAX_
NODES - Distinct
(session, name, namespace)triples the shim tracks. Raise withNROS_RMW_MAX_NODES; the default mirrors the executor’sMAX_NODES. - NROS_
RMW_ QOS_ PROFILE_ DEFAULT - Standard
rmw_qos_profile_default-equivalent. - NROS_
RMW_ QOS_ PROFILE_ PARAMETERS - Standard
rmw_qos_profile_parameters-equivalent. - NROS_
RMW_ QOS_ PROFILE_ SENSOR_ DATA - Standard
rmw_qos_profile_sensor_data-equivalent. - NROS_
RMW_ QOS_ PROFILE_ SERVICES_ DEFAULT - Standard
rmw_qos_profile_services_default-equivalent. - NROS_
RMW_ QOS_ PROFILE_ SYSTEM_ DEFAULT - Standard
rmw_qos_profile_system_default-equivalent — all sentinel.
Functions§
- backend_
registered - Phase 104.A — registry-presence probe. Returns
trueiff at least one backend is registered. Used byExecutor::opento detect “user forgot to register a backend before opening the session” and fail with a meaningful error. - backend_
resolution_ to_ ret - Phase 128.A.3 — map a
BackendResolutionto its canonicalNrosRmwRet.BackendResolution::Singleis not an error and returnsNROS_RMW_RET_OK; callers needing the vtable should pattern-match on the resolution itself. - error_
from_ ret - Map a
rmw_ret_treturned by a C-side vtable function back to aTransportErrorfor the Rust caller. Inverse ofret_from_error— used whennros-rmw-cffi’sCffiSessionetc. receive a code from the registered C backend. - event_
kind_ from_ c - Convert a C ABI event-kind discriminant to the trait-level
nros_rmw::EventKind. Replaces the retiredFrom<NrosRmwEventKind> for nros_rmw::EventKind. Unknown values map toMessageLost, mirroring the forward direction’s fallback. - event_
kind_ to_ c - Convert a trait-level
nros_rmw::EventKindto the C ABI discriminant. Replaces the retiredFrom<nros_rmw::EventKind> for NrosRmwEventKind. - nros_
rmw_ ⚠cffi_ lookup - Look up a backend’s vtable by name. Returns NULL if no backend
is registered under
name. - nros_
rmw_ ⚠cffi_ register Deprecated - Register a custom RMW backend vtable (legacy single-arg form).
- nros_
rmw_ ⚠cffi_ register_ named - Register a backend under a stable name. Multiple backends can
coexist; consumers select via
nros_rmw_cffi_lookupor the higher-levelExecutor::node_builder(...).rmw(...)path. - nros_
rmw_ ⚠cffi_ registered_ names - Diagnostic helper — fills
bufwith pointers to up tocapregistered backend names. Returns the number of names available (may exceedcap). Pointer-valid for the program’s lifetime. - nros_
rmw_ ⚠cffi_ set_ custom_ transport - Phase 115.A.2 — C entry point for installing a custom transport.
- nros_
rmw_ ⚠qos_ incompatibility_ mask - See
nros/rmw_entity.h. - resolve_
backend - Phase 128.A.3 — selection policy for the single-backend
Executor::open/nros::initpath. - ret_
from_ error - Map a
TransportErrorto the correspondingrmw_ret_tcode. - rmw_
compare_ ⚠gids_ equal - See
nros/rmw_entity.h. - rmw_
qos_ ⚠profile_ check_ compatible - See
nros/rmw_entity.h. - rmw_
severity_ of - Map
nros_log’s ladder onto upstream’s. - set_
backend_ log_ severity - Set the verbosity of every registered BACKEND’s own logging.
Type Aliases§
- Nros
RmwClient - Compat alias for the generated
rmw_client_t. - Nros
RmwCount Status - Compat alias for the generated
rmw_count_status_t. - Nros
RmwEvent Callback - Compat alias for the generated
rmw_status_event_callback_t(nullable —Option-wrapped fn pointer, per C ABI). - Nros
RmwEvent Kind - Compat alias for the generated
rmw_event_type_t::Type(C-unsigned-sized event-kind discriminant). - Nros
RmwEvent Payload - Compat alias for the generated
rmw_event_payload_tunion. - Nros
RmwLiveliness Changed Status - Compat alias for the generated
rmw_liveliness_changed_status_t. - Nros
RmwNode - Phase 376 W5/B1 — a graph node. The first argument of the four
create_*slots, in place of the fabricated per-call session view they used to take. - Nros
RmwPublisher - Compat alias for the generated
rmw_publisher_t. - Nros
RmwQos - Compat alias for the generated
rmw_qos_profile_t. - Nros
RmwRet - Compat alias for the generated
rmw_ret_ttypedef. Zero on success; negative on error. - Nros
RmwService - Compat alias for the generated
rmw_service_t. - Nros
RmwSession - Compat alias for the generated
rmw_session_t. - Nros
RmwSession Options - issue 0808 — session creation options; NULL means every default.
- Nros
RmwSubscription - Compat alias for the generated
rmw_subscription_t. - Nros
RmwVtable - Compat alias for the generated
nros_rmw_vtable_t.