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§
fn register_waker(&self, waker: &Waker)
fn close(&mut self)
Provided Methods§
Sourcefn push(&mut self, item: Self::Item) -> PushFuture<'_, Self> ⓘ
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.
§Cancel safety
If future is cancelled no item pushed to the RB.
Sourcefn push_iter_all<I: Iterator<Item = Self::Item>>(
&mut self,
iter: I,
) -> PushIterFuture<'_, Self, I> ⓘ
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:
true- iterator ended.false- the corresponding consumer was dropped.
§Cancel safety
If future is cancelled then remaining items are left in iterator.
You can get the iterator by using PushIterFuture::inner, PushIterFuture::inner_mut and PushIterFuture::into_inner.
Note that the iterator is Peekable.
Sourcefn wait_vacant(&mut self, count: usize) -> WaitVacantFuture<'_, Self> ⓘ
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.
§Cancel safety
You can safely cancel this future.
Sourcefn push_exact<'a: 'b, 'b>(
&'a mut self,
slice: &'b [Self::Item],
) -> PushSliceFuture<'a, 'b, Self> ⓘ
fn push_exact<'a: 'b, 'b>( &'a mut self, slice: &'b [Self::Item], ) -> PushSliceFuture<'a, 'b, Self> ⓘ
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.
§Cancel safety
On cancel the slice can be copied partially.
The number of items already copied can be examined by PushSliceFuture::count.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".