Skip to main content

Stream

Struct Stream 

Source
pub struct Stream { /* private fields */ }
Expand description

A subscription to a single topic on a pool-backed pub/sub region.

Returns Sample references that implement Deref<Target=[u8]>. These guards are safe – the block is held alive by atomic refcounting until the guard is dropped.

Implementations§

Source§

impl Stream

Source

pub fn try_recv(&self) -> Option<Sample<'_>>

Non-blocking: returns the next sample guard or None.

The returned guard implements Deref<Target=[u8]> – safe to read without unsafe. The block is held alive until the guard is dropped.

Uses a ring-window scan to handle multi-publisher scenarios where sequence numbers are claimed atomically and slots may be committed out of order.

Source

pub fn try_recv_typed<T: Pod>(&self) -> Option<TypedSample<'_, T>>

Non-blocking typed receive. Returns a TypedSample that dereferences to &T.

Uses the same ring-window scan as try_recv to handle multi-publisher scenarios.

Returns None if no new data is available or if the topic’s registered type size doesn’t match size_of::<T>().

Source

pub fn recv_typed<T: Pod>(&self) -> Result<TypedSample<'_, T>, Error>

Blocking typed receive with the default WaitStrategy.

§Errors

Returns Error::PublisherDead if the publisher heartbeat goes stale.

Source

pub fn recv_typed_with<T: Pod>( &self, strategy: WaitStrategy, ) -> Result<TypedSample<'_, T>, Error>

Blocking typed receive with a custom WaitStrategy.

§Errors

Returns Error::PublisherDead if the publisher heartbeat goes stale.

Source

pub fn recv_with(&self, strategy: WaitStrategy) -> Result<Sample<'_>, Error>

Blocking: waits for the next sample using the given WaitStrategy.

For BusySpin/YieldSpin/BackoffSpin: loops calling try_recv() with the strategy’s wait hint, checking heartbeat periodically.

For Adaptive: uses spin/yield phases, then falls through to the OS-assisted sleep path (futex/WaitOnAddress/WFE).

§Errors

Returns Error::PublisherDead if the publisher heartbeat goes stale.

Source

pub fn recv(&self) -> Result<Sample<'_>, Error>

Blocking: waits for the next sample using the default WaitStrategy (three-phase adaptive: spin -> yield -> OS sleep).

§Errors

Returns Error::PublisherDead if the publisher heartbeat goes stale.

Source

pub fn try_recv_pinned(&self) -> Option<PinnedGuard<'_>>

Non-blocking pinned receive. Returns a zero-overhead guard pointing directly into the pinned block.

The guard increments a shared reader count on creation and decrements on drop. The publisher checks this count before writing – if any readers exist, loan_pinned returns an error instead of causing UB.

Returns None if no new data has been published since the last recv.

Source

pub fn recv_pinned(&self) -> Result<PinnedGuard<'_>, Error>

Blocking pinned receive. Waits for the next pinned publish using the default WaitStrategy (three-phase adaptive: spin -> yield -> OS sleep).

§Errors

Returns Error::PublisherDead if the publisher heartbeat goes stale.

Source

pub fn recv_pinned_with( &self, strategy: WaitStrategy, ) -> Result<PinnedGuard<'_>, Error>

Blocking pinned receive with a custom WaitStrategy.

§Errors

Returns Error::PublisherDead if the publisher heartbeat goes stale.

Trait Implementations§

Source§

impl Debug for Stream

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for Stream

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl !Freeze for Stream

§

impl !RefUnwindSafe for Stream

§

impl Send for Stream

§

impl !Sync for Stream

§

impl Unpin for Stream

§

impl UnsafeUnpin for Stream

§

impl UnwindSafe for Stream

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.