pub struct EmbeddedRawPublisher<const TX_BUF: usize = nros_node::::executor::handles::EmbeddedRawPublisher::{constant#0}> { /* private fields */ }Expand description
Typeless publisher handle. Use when the wire format is not ROS CDR (e.g. PX4 uORB raw POD bytes, custom binary protocols).
Two publish paths:
publish_raw: user supplies a&[u8], backend memcpys into its outbound buffer. One copy.try_loan: backend (or per-publisher arena fallback) hands user a&mut [u8]slice. User writes in place.PublishLoan::committriggers the wire write. Zero-copy on backends with native lending (Phase 99: zenoh-picounstable-zenoh-api, XRCE-DDS); single-memcpy fallback on backends without (uORB).
The const-generic TX_BUF sizes the inline arena slot (default
DEFAULT_LOAN_BUF). Loans larger than TX_BUF return
LoanError::TooLarge.
Implementations§
Source§impl<const TX_BUF: usize> EmbeddedRawPublisher<TX_BUF>
impl<const TX_BUF: usize> EmbeddedRawPublisher<TX_BUF>
Sourcepub fn new(
handle: <CffiSession as Session>::PublisherHandle,
) -> EmbeddedRawPublisher<TX_BUF>
pub fn new( handle: <CffiSession as Session>::PublisherHandle, ) -> EmbeddedRawPublisher<TX_BUF>
Construct an EmbeddedRawPublisher from a backend-allocated
RmwPublisher handle. Public so external extension crates
(e.g. nros-px4 for typed uORB wrappers) can wrap a handle
they obtained directly from the active session via
[crate::Node::session_mut] + a backend-specific create method.
Most users should not call this — use [crate::Node::create_publisher]
or [crate::Node::create_publisher_raw] instead.
Sourcepub fn supports_event(&self, kind: EventKind) -> bool
pub fn supports_event(&self, kind: EventKind) -> bool
Phase 108.A — true if the active backend can fire the named
event for this raw publisher.
Sourcepub fn publish_raw(&self, data: &[u8]) -> Result<(), NodeError>
pub fn publish_raw(&self, data: &[u8]) -> Result<(), NodeError>
Publish a pre-encoded byte slice. The byte format depends entirely on the active RMW backend:
- zenoh / XRCE-DDS / DDS: CDR-encoded payload including the 4-byte CDR header.
- uORB: raw POD struct bytes (no header). Length must equal
size_of::<T::Msg>()for the registered topic.
Sourcepub fn publish_raw_with_attachment(
&self,
data: &[u8],
attachment: &[u8],
) -> Result<(), NodeError>
pub fn publish_raw_with_attachment( &self, data: &[u8], attachment: &[u8], ) -> Result<(), NodeError>
Phase 128.F.4 — raw publish with a wire-level attachment block.
attachment rides alongside the payload on backends that
natively support it (zenoh-pico, Cyclone DDS). Backends without
native support silently discard attachment and fall back to
the regular publish_raw path — the
default Publisher::publish_raw_with_attachment body in
nros-rmw does this delegation.
Primary use case: cross-RMW bridges stamp the source backend’s
RMW name as bridge_origin so a paired return bridge can drop
echoed frames deterministically.
Sourcepub fn assert_liveliness(&self) -> Result<(), NodeError>
pub fn assert_liveliness(&self) -> Result<(), NodeError>
Phase 108.B — manually assert this publisher’s liveliness.
Required for QosLivelinessPolicy::ManualByTopic /
ManualByNode. No-op for AUTOMATIC / NONE.
Sourcepub fn try_loan(&self, len: usize) -> Result<PublishLoan<'_, TX_BUF>, LoanError>
pub fn try_loan(&self, len: usize) -> Result<PublishLoan<'_, TX_BUF>, LoanError>
Reserve a writable slot of len bytes. Caller writes into the
returned PublishLoan and calls PublishLoan::commit to
publish. Never blocks; returns LoanError::WouldBlock when the
slot is already in use (arena fallback) or the backend’s outbound
stream is full (lending path), and LoanError::TooLarge when
len exceeds the publisher’s slot capacity.
With the rmw-lending cargo feature on, this dispatches to the
active backend’s SlotLending::try_lend_slot
— zero-copy on backends that natively lend (zenoh-pico via
z_bytes_from_static_buf, XRCE-DDS via uxr_prepare_output_stream).
Without rmw-lending, the arena fallback is used: caller fills a
per-publisher inline slot, commit calls
the backend’s publish_raw (single memcpy into the backend’s
outbound buffer, same as publish_raw directly).
Sourcepub fn loan_with_timeout(
&self,
len: usize,
executor: &mut Executor,
timeout: Duration,
) -> Result<PublishLoan<'_, TX_BUF>, LoanError>
pub fn loan_with_timeout( &self, len: usize, executor: &mut Executor, timeout: Duration, ) -> Result<PublishLoan<'_, TX_BUF>, LoanError>
Sync blocking loan with timeout. Spins the executor until the
arena slot is free or timeout elapses.
Useful when you publish from a sync context that owns the executor and want to block on a busy arena (rare — single-slot arena means contention only when concurrent task tries the same publisher, in which case the offending other task should have committed promptly).
Sourcepub fn loan(&self, len: usize) -> LoanFuture<'_, TX_BUF>
pub fn loan(&self, len: usize) -> LoanFuture<'_, TX_BUF>
Async-await on a free loan slot. Returns the loan as soon as the arena’s busy flag clears (no-lending path) or as soon as the backend’s outbound stream has room (lending path).
Phase 99.H’: cancellation-safe Future. Registers the task’s
waker on the arena’s [AtomicWaker] before checking
[try_loan]; another task’s commit / discard calls
[TxArena::release] which wakes us. Dropping the future before
it resolves removes nothing from any wait queue (single-slot
AtomicWaker semantics: only the latest registration matters)
and explicitly wakes another waiter so the next task in line
gets a poll. No PublishLoan is materialised on cancel paths.