Skip to main content

Reader

Struct Reader 

Source
pub struct Reader<T: Clone + Send> { /* private fields */ }
Expand description

Owned, ergonomic handle over an erased BufferReader.

Returned by Consumer::subscribe. This is the “boxed lane”: one indirect call per recv, zero AimDB-added heap allocations per message. (The generic monomorphized Reader<T, B> fast lane remains dormant.)

Implementations§

Source§

impl<T: Clone + Send> Reader<T>

Source

pub fn new(inner: Box<dyn BufferReader<T> + Send>) -> Self

Wrap an erased reader in an ergonomic handle.

Source

pub async fn recv(&mut self) -> Result<T, DbError>

Receive the next value, awaiting until one is available.

Allocation-free: wraps the erased reader’s poll_recv via core::future::poll_fn.

§Behavior by Buffer Type
  • SPMC Ring: Returns next value, or Lagged(n) if fell behind
  • SingleLatest: Waits for value change, returns most recent
  • Mailbox: Waits for slot value, takes and clears it
Source

pub fn try_recv(&mut self) -> Result<T, DbError>

Non-blocking receive — returns immediately.

Returns Err(DbError::BufferEmpty) if no pending values.

Auto Trait Implementations§

§

impl<T> !RefUnwindSafe for Reader<T>

§

impl<T> !Sync for Reader<T>

§

impl<T> !UnwindSafe for Reader<T>

§

impl<T> Freeze for Reader<T>
where Box<dyn BufferReader<T> + Send>: Freeze,

§

impl<T> Send for Reader<T>
where Box<dyn BufferReader<T> + Send>: Send,

§

impl<T> Unpin for Reader<T>
where Box<dyn BufferReader<T> + Send>: Unpin,

§

impl<T> UnsafeUnpin for Reader<T>
where Box<dyn BufferReader<T> + Send>: UnsafeUnpin,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.