async_ringbuf::traits::producer

Trait 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,

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§