Trait async_ringbuf::traits::producer::AsyncProducer

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

    // Provided methods
    fn is_closed(&self) -> bool { ... }
    fn push(&mut self, item: Self::Item) -> PushFuture<'_, Self>  { ... }
    fn push_iter_all<I: Iterator<Item = Self::Item>>(
        &mut self,
        iter: I,
    ) -> PushIterFuture<'_, Self, I>  { ... }
    fn wait_vacant(&mut self, count: usize) -> WaitVacantFuture<'_, Self>  { ... }
    fn push_exact<'a: 'b, 'b>(
        &'a mut self,
        slice: &'b [Self::Item],
    ) -> PushSliceFuture<'a, 'b, Self> 
       where Self::Item: Copy { ... }
    fn poll_ready(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<bool> { ... }
    fn poll_write(
        self: Pin<&mut Self>,
        cx: &mut Context<'_>,
        buf: &[u8],
    ) -> Poll<Result<usize>>
       where Self: AsyncProducer<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 consumer was closed.

source

fn push(&mut self, item: Self::Item) -> PushFuture<'_, Self>

Push item to the ring buffer waiting asynchronously if the buffer is full.

Future returns:

  • Ok - item successfully pushed.
  • Err(item) - the corresponding consumer was dropped, item is returned back.
source

fn push_iter_all<I: Iterator<Item = Self::Item>>( &mut self, iter: I, ) -> PushIterFuture<'_, Self, I>

Push items from iterator waiting asynchronously if the buffer is full.

Future returns:

  • Ok - iterator ended.
  • Err(iter) - the corresponding consumer was dropped, remaining iterator is returned back.
source

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

Wait for the buffer to have at least count free places for items or to close.

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

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

source

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

Copy slice contents to the buffer waiting asynchronously if the buffer is full.

Future returns:

  • Ok - all slice contents are copied.
  • Err(count) - the corresponding consumer was dropped, number of copied items returned.
source

fn poll_ready(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<bool>

source

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

Object Safety§

This trait is not object safe.

Implementors§