pub struct RawSubscription<const RX_BUF: usize = nros_node::::executor::handles::RawSubscription::{constant#0}> { /* private fields */ }Expand description
Typeless subscription handle. Counterpart of EmbeddedRawPublisher.
The user owns the decoding step: call try_recv_raw
to fill an internal buffer with bytes whose format depends on the active
RMW backend, then interpret them however is appropriate (memcpy, custom
parser, …).
Implementations§
Source§impl<const RX_BUF: usize> RawSubscription<RX_BUF>
impl<const RX_BUF: usize> RawSubscription<RX_BUF>
Sourcepub fn new(
handle: <CffiSession as Session>::SubscriberHandle,
) -> RawSubscription<RX_BUF>
pub fn new( handle: <CffiSession as Session>::SubscriberHandle, ) -> RawSubscription<RX_BUF>
Construct a RawSubscription from a backend-allocated
RmwSubscriber 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_subscription] or
[crate::Node::create_subscription_raw] instead.
Sourcepub fn try_recv_raw(&mut self) -> Result<Option<usize>, NodeError>
pub fn try_recv_raw(&mut self) -> Result<Option<usize>, NodeError>
Try to receive raw bytes (non-blocking). Returns Ok(Some(len))
with the message length on success; the bytes live in
buffer until the next call.
Sourcepub fn try_recv_raw_with_attachment(
&mut self,
att_buf: &mut [u8],
) -> Result<Option<(usize, usize)>, NodeError>
pub fn try_recv_raw_with_attachment( &mut self, att_buf: &mut [u8], ) -> Result<Option<(usize, usize)>, NodeError>
Phase 128.F.4 — raw receive that also surfaces the incoming sample’s wire-level attachment block.
Returns Ok(Some((payload_len, attachment_len))). The payload
lives in buffer; the attachment is written
into caller-supplied att_buf. attachment_len == 0 means
the incoming sample carried no attachment.
Backends without native attachment support delegate to
try_recv_raw and always report
attachment_len == 0 (default Subscriber trait body in
nros-rmw).
Sourcepub fn try_recv_sequence(
&mut self,
buf: &mut [u8],
per_msg_cap: usize,
max_msgs: usize,
out_lens: &mut [usize],
) -> Result<usize, NodeError>
pub fn try_recv_sequence( &mut self, buf: &mut [u8], per_msg_cap: usize, max_msgs: usize, out_lens: &mut [usize], ) -> Result<usize, NodeError>
Phase 124.D.1 — burst-take. Drain up to max_msgs queued
samples into the caller-supplied contiguous block in one
call, with the i-th sample at
buf[i * per_msg_cap .. i * per_msg_cap + out_lens[i]].
Returns the number of messages delivered.
Backends without a native batch take inherit the
Subscriber::try_recv_sequence default body which loop-drives
try_recv_raw — same shape, same observable result; the
batched API just lets sensor loops commit to the call shape
regardless of backend support.
Sourcepub fn register_waker(&self, waker: &Waker)
pub fn register_waker(&self, waker: &Waker)
Phase 122.3.c.6.e — register a Waker that fires when a new
message arrives. Mirror of the existing service-server /
service-client wake plumbing. No-op on backends that don’t
support waking — caller falls back to polling.
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 subscription.
Sourcepub fn on_liveliness_changed<F>(&mut self, cb: F) -> Result<(), NodeError>
pub fn on_liveliness_changed<F>(&mut self, cb: F) -> Result<(), NodeError>
Phase 108.A — register a callback for LivelinessChanged.
Sourcepub fn on_requested_deadline_missed<F>(
&mut self,
deadline: Duration,
cb: F,
) -> Result<(), NodeError>
pub fn on_requested_deadline_missed<F>( &mut self, deadline: Duration, cb: F, ) -> Result<(), NodeError>
Phase 108.A — register a callback for RequestedDeadlineMissed.
Sourcepub fn on_message_lost<F>(&mut self, cb: F) -> Result<(), NodeError>
pub fn on_message_lost<F>(&mut self, cb: F) -> Result<(), NodeError>
Phase 108.A — register a callback for MessageLost.
Sourcepub fn buffer(&self) -> &[u8] ⓘ
pub fn buffer(&self) -> &[u8] ⓘ
Get the receive buffer (valid after try_recv_raw).
Sourcepub fn try_borrow(&mut self) -> Result<Option<RecvView<'_>>, NodeError>
pub fn try_borrow(&mut self) -> Result<Option<RecvView<'_>>, NodeError>
Try to borrow the next available message in place. Returns
Ok(None) if no message is ready; never blocks.
The returned RecvView borrows the subscriber’s internal
receive buffer. Lifetime is tied to &mut self — only one view
can be live at a time, and the next try_borrow / try_recv_raw
call invalidates the previous view’s bytes.
View is !Send + !Sync to discourage holding it across .await
or thread boundaries (would block subsequent receives on the
same subscriber).
Sourcepub async fn borrow(&mut self) -> Result<RecvView<'_>, NodeError>
pub async fn borrow(&mut self) -> Result<RecvView<'_>, NodeError>
Async-await on the next message, returning a RecvView.
Mirrors the Subscription::recv pattern but typeless.
Backend wake source: Subscriber::register_waker. Same race-
safe register-then-check ordering as Subscription::recv.
Sourcepub fn borrow_with_timeout(
&mut self,
executor: &mut Executor,
timeout: Duration,
) -> Result<Option<RecvView<'_>>, NodeError>
pub fn borrow_with_timeout( &mut self, executor: &mut Executor, timeout: Duration, ) -> Result<Option<RecvView<'_>>, NodeError>
Sync blocking borrow with timeout. Spins the executor until a
message is available or timeout elapses.
Returns Ok(Some(view)) on success, Ok(None) on timeout.
The view’s lifetime is tied to &mut self.