pub struct EmbeddedPublisher<M> { /* private fields */ }Expand description
Typed publisher handle.
Two methods, both byte-oriented at the wire:
publish/publish_with_buffer— accept&M: RosMessage, CDR-encode into a stack buffer, then callPublisher::publish_raw.publish_raw— accepts pre-encoded CDR bytes for callers that already produced the wire payload.
No typed loan() exists. Loan/borrow live exclusively on
EmbeddedRawPublisher / RawSubscription. try_loan(len)
requires the byte length up front, which CDR ser/de can only
discover after encoding — the two APIs are incompatible by
construction. See docs/design/0010-zero-copy-raw-api.md decision D7.
Implementations§
Source§impl<M> EmbeddedPublisher<M>where
M: RosMessage,
impl<M> EmbeddedPublisher<M>where
M: RosMessage,
Sourcepub fn publish(&self, msg: &M) -> Result<(), NodeError>
pub fn publish(&self, msg: &M) -> Result<(), NodeError>
Publish a message using the default buffer size.
Sourcepub fn publish_with_buffer<const BUF: usize>(
&self,
msg: &M,
) -> Result<(), NodeError>
pub fn publish_with_buffer<const BUF: usize>( &self, msg: &M, ) -> Result<(), NodeError>
Publish a message with a custom buffer size.
Sourcepub fn publish_raw(&self, data: &[u8]) -> Result<(), NodeError>
pub fn publish_raw(&self, data: &[u8]) -> Result<(), NodeError>
Publish raw CDR-encoded data (must include CDR header).
Sourcepub fn publish_streamed<F>(
&self,
total_len: usize,
writer: F,
) -> Result<(), NodeError>
pub fn publish_streamed<F>( &self, total_len: usize, writer: F, ) -> Result<(), NodeError>
Phase 124.E.1 — streamed publish. Use a closure-driven writer to serialise straight into the backend’s outbound buffer without a per-publisher staging copy. Saves on RAM-constrained nodes that publish multi-KB payloads.
The writer closure receives a [StreamWriter] mutable
reference and uses [StreamWriter::write] / [extend] /
[reserved_len] to fill the slot in chunks. The total
payload length must be declared up-front via
[StreamWriter::reserve_total]; the backend allocates that
many bytes in its outbound buffer before any chunks land.
Backends without a native stream slot fall through to a
stack-allocated staging buffer (capped at 4 KiB) + a single
publish_raw — same observable result, just no zero-staging
win for the big-message case.
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 publishers configured with
[QosLivelinessPolicy::ManualByTopic] /
[QosLivelinessPolicy::ManualByNode]. No-op for AUTOMATIC /
NONE kinds. Returns Err(Unsupported) if the backend doesn’t
implement manual liveliness.
Sourcepub fn supports_event(&self, kind: EventKind) -> bool
pub fn supports_event(&self, kind: EventKind) -> bool
true if the active backend can fire the named event for this
publisher.
Sourcepub fn on_liveliness_lost<F>(&mut self, cb: F) -> Result<(), NodeError>
pub fn on_liveliness_lost<F>(&mut self, cb: F) -> Result<(), NodeError>
Register a callback for LivelinessLost. Fires when this
publisher misses its own liveliness assertion deadline.