pub struct EmbeddedRawPublisher<const TX_BUF: usize = DEFAULT_LOAN_BUF> { /* 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_serialized: user supplies a&[u8], backend memcpys into its outbound buffer. One copy.try_loan: backend (or, withoutrmw-lending, a per-publisher arena) hands user a&mut [u8]slice. User writes in place.PublishLoan::committriggers the wire write. Withrmw-lendingit is zero-copy where the backend lends — zenoh, the only one that fills the loan slots (no payload copy, measured in issue 0814) — and REFUSED where it does not (Cyclone, XRCE, uORB):LoanError::Backend(Unsupported), permanent, the same in every build. The arena path is one copy, the same aspublish_serialized.
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 const fn format(&self) -> SerializationFormatId
pub const fn format(&self) -> SerializationFormatId
RFC-0088 — the serialization format this publisher expects its raw
bytes to already be in. Counterpart to RawSubscription::format.
Sourcepub fn new(handle: RmwPublisher) -> Self
pub fn new(handle: RmwPublisher) -> Self
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
NodeHandle::session_mut + a backend-specific create method.
Most users should not call this — use NodeHandle::create_publisher
or NodeHandle::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_serialized(&self, data: &[u8]) -> Result<(), NodeError>
pub fn publish_serialized(&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(&self, data: &[u8]) -> Result<(), NodeError>
👎Deprecated since 0.6.0: renamed to publish_serialized (phase-515 C8)
pub fn publish_raw(&self, data: &[u8]) -> Result<(), NodeError>
renamed to publish_serialized (phase-515 C8)
Renamed to publish_serialized (phase-515
C8), the transmit word of the receive side’s take_serialized.
Sourcepub fn publish_serialized_with_attachment(
&self,
data: &[u8],
attachment: &[u8],
) -> Result<(), NodeError>
pub fn publish_serialized_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_serialized 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 publish_raw_with_attachment(
&self,
data: &[u8],
attachment: &[u8],
) -> Result<(), NodeError>
👎Deprecated since 0.6.0: renamed to publish_serialized_with_attachment (phase-515 C8)
pub fn publish_raw_with_attachment( &self, data: &[u8], attachment: &[u8], ) -> Result<(), NodeError>
renamed to publish_serialized_with_attachment (phase-515 C8)
Renamed to
publish_serialized_with_attachment
(phase-515 C8).
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. See
EmbeddedPublisher::assert_liveliness for what Err(Unsupported)
means per backend.
Sourcepub fn get_gid(&self) -> Result<[u8; 24], NodeError>
pub fn get_gid(&self) -> Result<[u8; 24], NodeError>
This publisher’s own global identifier — upstream
rmw_get_gid_for_publisher. See EmbeddedPublisher::get_gid for
the three bounds on what the bytes mean.
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 zenoh
(z_bytes_from_static_buf), the only backend that lends; on
Cyclone, XRCE and uORB it returns LoanError::Backend(Unsupported),
a permanent answer (issue 0814): use publish_raw there.
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 topic_name(&self) -> &str
pub fn topic_name(&self) -> &str
The topic this publisher was created on — see
EmbeddedPublisher::topic_name for the contract and for why the
accessor is here rather than on the RMW trait. phase-444.