Skip to main content

RawSubscription

Struct RawSubscription 

Source
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>

Source

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.

Source

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.

Source

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).

Source

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.

Source

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.

Source

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.

Source

pub fn on_liveliness_changed<F>(&mut self, cb: F) -> Result<(), NodeError>
where F: FnMut(LivelinessChangedStatus) + Send + 'static,

Phase 108.A — register a callback for LivelinessChanged.

Source

pub fn on_requested_deadline_missed<F>( &mut self, deadline: Duration, cb: F, ) -> Result<(), NodeError>
where F: FnMut(CountStatus) + Send + 'static,

Phase 108.A — register a callback for RequestedDeadlineMissed.

Source

pub fn on_message_lost<F>(&mut self, cb: F) -> Result<(), NodeError>
where F: FnMut(CountStatus) + Send + 'static,

Phase 108.A — register a callback for MessageLost.

Source

pub fn buffer(&self) -> &[u8]

Get the receive buffer (valid after try_recv_raw).

Source

pub fn has_data(&self) -> bool

Check if data is available without consuming it.

Source

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).

Source

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.

Source

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.

Trait Implementations§

Source§

impl<const RX_BUF: usize> Drop for RawSubscription<RX_BUF>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<const RX_BUF: usize> Freeze for RawSubscription<RX_BUF>

§

impl<const RX_BUF: usize> RefUnwindSafe for RawSubscription<RX_BUF>

§

impl<const RX_BUF: usize = nros_node::::executor::handles::RawSubscription::{constant#0}> !Send for RawSubscription<RX_BUF>

§

impl<const RX_BUF: usize = nros_node::::executor::handles::RawSubscription::{constant#0}> !Sync for RawSubscription<RX_BUF>

§

impl<const RX_BUF: usize> Unpin for RawSubscription<RX_BUF>

§

impl<const RX_BUF: usize> UnsafeUnpin for RawSubscription<RX_BUF>

§

impl<const RX_BUF: usize> UnwindSafe for RawSubscription<RX_BUF>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.