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§
fn register_waker(&self, waker: &Waker)
fn close(&mut self)
Provided Methods§
Sourcefn pop(&mut self) -> PopFuture<'_, Self> ⓘ
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.
Sourcefn wait_occupied(&mut self, count: usize) -> WaitOccupiedFuture<'_, Self> ⓘ
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.
Sourcefn pop_exact<'a: 'b, 'b>(
&'a mut self,
slice: &'b mut [Self::Item],
) -> PopSliceFuture<'a, 'b, Self> ⓘ
fn pop_exact<'a: 'b, 'b>( &'a mut self, slice: &'b mut [Self::Item], ) -> PopSliceFuture<'a, 'b, Self> ⓘ
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.
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>>
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.