Trait async_ringbuf::traits::consumer::AsyncConsumer

source ·
pub trait AsyncConsumer: Consumer {
    // Required methods
    fn register_waker(&self, waker: &Waker);
    fn close(&mut self);

    // Provided methods
    fn is_closed(&self) -> bool { ... }
    fn pop(&mut self) -> PopFuture<'_, Self>  { ... }
    fn wait_occupied(&mut self, count: usize) -> WaitOccupiedFuture<'_, Self>  { ... }
    fn pop_exact<'a: 'b, 'b>(
        &'a mut self,
        slice: &'b mut [Self::Item],
    ) -> PopSliceFuture<'a, 'b, Self> 
       where Self::Item: Copy { ... }
    fn pop_until_end<'a: 'b, 'b>(
        &'a mut self,
        vec: &'b mut Vec<Self::Item>,
    ) -> PopVecFuture<'a, 'b, Self>  { ... }
    fn poll_next(
        self: Pin<&mut Self>,
        cx: &mut Context<'_>,
    ) -> Poll<Option<Self::Item>>
       where Self: Unpin { ... }
    fn poll_read(
        self: Pin<&mut Self>,
        cx: &mut Context<'_>,
        buf: &mut [u8],
    ) -> Poll<Result<usize>>
       where Self: AsyncConsumer<Item = u8> + Unpin { ... }
}

Required Methods§

source

fn register_waker(&self, waker: &Waker)

source

fn close(&mut self)

Provided Methods§

source

fn is_closed(&self) -> bool

Whether the corresponding producer was closed.

source

fn pop(&mut self) -> PopFuture<'_, Self>

Pop item from the ring buffer waiting asynchronously if the buffer is empty.

Future returns:

  • Some(item) - an item is taken.
  • None - the buffer is empty and the corresponding producer was dropped.
source

fn wait_occupied(&mut self, count: usize) -> WaitOccupiedFuture<'_, Self>

Wait for the buffer to contain at least count items or to close.

In debug mode panics if count is greater than buffer capacity.

The method takes &mut self because only single WaitOccupiedFuture is allowed at a time.

source

fn pop_exact<'a: 'b, 'b>( &'a mut self, slice: &'b mut [Self::Item], ) -> PopSliceFuture<'a, 'b, Self>
where Self::Item: Copy,

Pop item from the ring buffer waiting asynchronously if the buffer is empty.

Future returns:

  • Ok - the whole slice is filled with the items from the buffer.
  • Err(count) - the buffer is empty and the corresponding producer was dropped, number of items copied to slice is returned.
source

fn pop_until_end<'a: 'b, 'b>( &'a mut self, vec: &'b mut Vec<Self::Item>, ) -> PopVecFuture<'a, 'b, Self>

source

fn poll_next( self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll<Option<Self::Item>>
where Self: Unpin,

source

fn poll_read( self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &mut [u8], ) -> Poll<Result<usize>>
where Self: AsyncConsumer<Item = u8> + Unpin,

Object Safety§

This trait is not object safe.

Implementors§