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 / Subscriber / 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>.
Modules§
- 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
Publisher - Publisher backed by a C vtable.
- CffiRmw
- RMW factory for the C function table backend.
- Cffi
Service Client - Service client backed by a C vtable.
- Cffi
Service Server - Service server backed by a C vtable.
- Cffi
Session - Session backed by a C vtable.
- Cffi
Subscriber - Subscriber backed by a C vtable.
- Nros
RmwCount Status - Count payload mirror.
- Nros
RmwLiveliness Changed Status - Liveliness payload mirror.
- Nros
RmwPublisher - Publisher entity. Mirrors
nros_rmw_publisher_t. - Nros
RmwQos - Full DDS-shaped QoS profile. Mirrors
nros_rmw_qos_tfrom<nros/rmw_entity.h>. - Nros
RmwService Client - Service-client entity. Mirrors
nros_rmw_service_client_t. - Nros
RmwService Server - Service-server entity. Mirrors
nros_rmw_service_server_t. - Nros
RmwSession - Per-process RMW session. Mirrors
nros_rmw_session_t. - Nros
RmwSubscriber - Subscriber entity. Mirrors
nros_rmw_subscriber_t. - Nros
RmwVtable - C function table for an RMW backend.
Enums§
- Backend
Resolution - Phase 128.A.3 — outcome of
resolve_backend. - Nros
RmwEvent Kind - Tier-1 event kinds. Stable u8 values matching
nros_rmw_event_kind_tin the C header. - Nros
RmwLiveliness Kind - Liveliness kind values for
NrosRmwQos::liveliness_kind.
Constants§
- MAX_
BACKENDS - Compile-time max number of concurrently registered backends.
Set via
NROS_RMW_MAX_BACKENDSenv var at build time (build.rs). Default 8. - 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. - NROS_
RMW_ RET_ AMBIGUOUS_ BACKEND - Phase 128.A.3 — more than one backend is linked and no
NROS_RMW=<name>selector was supplied. Caller must either set the env var or useExecutor::open_multi. - NROS_
RMW_ RET_ BAD_ ALLOC - Memory allocation failed.
- NROS_
RMW_ RET_ BUFFER_ TOO_ SMALL - Caller buffer smaller than the data the backend wants to deliver.
- NROS_
RMW_ RET_ CONNECTION_ FAILED - Phase 155.B.3 — backend reached the wire but couldn’t establish a
session. Maps to / from
TransportError::ConnectionFailed/Disconnected. Distinct fromNROS_RMW_RET_ERRORso callers can tell “can’t reach the router” from “internal backend invariant tripped”. - NROS_
RMW_ RET_ ERROR - Generic failure not covered by a more specific code.
- NROS_
RMW_ RET_ INCOMPATIBLE_ ABI - Phase 115.A.2 — caller’s vtable struct has an
abi_versionthe runtime doesn’t know. Returned by entry points that take a versioned vtable struct (nros_set_custom_transport,nros_cpp_set_custom_transport, …) whenvtable.abi_version != NROS_RMW_*_ABI_VERSION_VN. - NROS_
RMW_ RET_ INCOMPATIBLE_ QOS - QoS profiles incompatible in a way the backend cannot reconcile.
- NROS_
RMW_ RET_ INVALID_ ARGUMENT - Caller supplied a NULL pointer or an out-of-range value.
- NROS_
RMW_ RET_ LOAN_ NOT_ SUPPORTED - Backend does not support loaned messages on this entity, or slot in use.
- NROS_
RMW_ RET_ MESSAGE_ TOO_ LARGE - Incoming message exceeded the backend’s static capacity.
- NROS_
RMW_ RET_ NODE_ NAME_ NON_ EXISTENT - Request referenced a node that does not exist in this session.
- NROS_
RMW_ RET_ NO_ BACKEND - Phase 128.A.3 —
Executor::open/nros::initcould not pick a unique backend because nonros-rmw-*crate (or static lib) is linked into this binary. - NROS_
RMW_ RET_ NO_ DATA - No data on a non-blocking receive (distinct from
TIMEOUT). - NROS_
RMW_ RET_ OK - Operation completed successfully.
- NROS_
RMW_ RET_ TIMEOUT - Operation deadline elapsed before completion.
- NROS_
RMW_ RET_ TOPIC_ NAME_ INVALID - Topic, service, or action name failed validation.
- NROS_
RMW_ RET_ UNKNOWN_ BACKEND - Phase 128.A.3 — selector pointed at a backend name that is not
in the registry (mis-spelling or missing
nros-rmw-<name>dep). - NROS_
RMW_ RET_ UNSUPPORTED - The backend does not implement this operation.
- NROS_
RMW_ RET_ WOULD_ BLOCK - Resource momentarily unavailable; caller should retry.
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
nros_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. - 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.
- resolve_
backend - Phase 128.A.3 — selection policy for the single-backend
Executor::open/nros::initpath. - ret_
from_ error - Map a
TransportErrorto the correspondingnros_rmw_ret_tcode.
Type Aliases§
- Nros
RmwEvent Callback - C callback signature. Matches
nros_rmw_event_callback_t. - Nros
RmwRet - Signed 32-bit status code mirroring the C
nros_rmw_ret_ttypedef. Zero on success; negative on error.
Unions§
- Nros
RmwEvent Payload - Borrow-shaped payload union mirror. C-side ABI — runtime-checked kind tag selects which member is valid.