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.
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:
Ok
- iterator ended.Err(iter)
- the corresponding consumer was dropped, remaining iterator is returned back.
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.
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.
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>>
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.