nros_rmw/lib.rs
1//! RMW (ROS Middleware) abstraction layer for nros.
2//!
3//! This crate provides the middleware-agnostic transport traits that
4//! backend crates (`nros-rmw-zenoh`, `nros-rmw-xrce`) implement.
5//! Application code depends on these traits, not on a concrete backend,
6//! so the transport can be swapped at compile time via Cargo features.
7//!
8//! # Trait hierarchy
9//!
10//! ```text
11//! Rmw — top-level factory, creates Sessions
12//! └─ Session — connection lifecycle, creates handles
13//! ├─ Publisher — publish serialised messages
14//! ├─ Subscriber — receive messages (polling or callback)
15//! ├─ ServiceServer — request/reply (server side)
16//! └─ ServiceClient — request/reply (client side)
17//! ```
18//!
19//! See [`traits`] for the full trait definitions.
20//!
21//! # Features
22//!
23//! - `std` — Enable standard library support
24//! - `alloc` — Enable heap allocation
25//!
26//! # Synchronization Backends
27//!
28//! - `sync-spin` — Use `spin::Mutex` (default, works everywhere)
29//! - `sync-critical-section` — Use critical sections (RTIC/Embassy compatible)
30
31#![no_std]
32
33#[cfg(feature = "std")]
34extern crate std;
35
36#[cfg(feature = "alloc")]
37extern crate alloc;
38
39pub mod custom_transport;
40pub mod event;
41pub mod sync;
42pub mod traits;
43pub mod type_descriptor;
44
45#[cfg(feature = "safety-e2e")]
46pub mod safety;
47
48// Phase 108 — status-event surface.
49pub use event::{
50 CountStatus, DeadlineMissedStatus, EventCallback, EventKind, EventPayload,
51 LivelinessChangedStatus, MessageLostStatus, payload_from_raw,
52};
53
54// Phase 115.A — runtime-pluggable custom transport vtable.
55pub use custom_transport::{
56 NROS_TRANSPORT_OPS_ABI_VERSION_V1, NrosTransportOps, peek_custom_transport,
57 set_custom_transport, take_custom_transport,
58};
59
60// Phase 248 (C2) — generic per-type descriptor registration seam.
61pub use type_descriptor::{
62 TypeDescriptorRegistrar, has_type_descriptor_registrar, register_type_descriptor,
63 set_type_descriptor_registrar,
64};
65
66// Re-export safety types when feature is enabled
67#[cfg(feature = "safety-e2e")]
68pub use safety::{IntegrityStatus, SafetyValidator, crc32};
69
70// Re-export main types
71pub use traits::{
72 ActionInfo, LocatorProtocol, Publisher, QosDurabilityPolicy, QosHistoryPolicy,
73 QosLivelinessPolicy, QosOverride, QosOverrideRole, QosOverrideValue, QosPolicyMask,
74 QosReliabilityPolicy, QosSettings, Rmw, RmwConfig, ServiceClientTrait, ServiceInfo,
75 ServiceRequest, ServiceServerTrait, Session, SessionMode, Subscriber, TopicInfo, Transport,
76 TransportConfig, TransportError, locator_protocol, validate_locator,
77};
78
79// Re-export `MessageInfo` from nros-core so backends implementing
80// `Subscriber::try_recv_raw_with_info` don't need their own direct
81// nros-core dep.
82pub use nros_core::MessageInfo;
83
84// Phase 99 — zero-copy raw API: SlotLending / SlotBorrowing traits.
85// Backends opt in by impl'ing these (and forwarding their own `lending`
86// feature to `nros-rmw/lending`).
87#[cfg(feature = "lending")]
88pub use traits::{SlotBorrowing, SlotLending};