BufferReader

Trait BufferReader 

Source
pub trait BufferReader<T: Clone + Send>: Send {
    // Required method
    fn recv(
        &mut self,
    ) -> Pin<Box<dyn Future<Output = Result<T, DbError>> + Send + '_>>;
}
Expand description

Reader trait for consuming values from a buffer

All read operations are async. Each reader is independent with its own state.

§Error Handling

  • Ok(value) - Successfully received a value
  • Err(BufferLagged) - Missed messages (SPMC ring only, can continue)
  • Err(BufferClosed) - Buffer closed (graceful shutdown)

Required Methods§

Source

fn recv( &mut self, ) -> Pin<Box<dyn Future<Output = Result<T, DbError>> + Send + '_>>

Receive the next value (async)

Waits for the next available value. Returns immediately if buffered.

§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

Implementors§