pub struct Receiver<T> { /* private fields */ }
Expand description
The receiving half of a channel. Reads are asynchronous.
Implementations§
Source§impl<T> Receiver<T>
impl<T> Receiver<T>
Sourcepub fn into_sync(self) -> SyncReceiver<T>
pub fn into_sync(self) -> SyncReceiver<T>
Converts asynchronous Receiver
to SyncReceiver
.
Sourcepub fn recv_batch(
&self,
element_limit: usize,
) -> impl Future<Output = Vec<T>> + '_
pub fn recv_batch( &self, element_limit: usize, ) -> impl Future<Output = Vec<T>> + '_
Sourcepub fn recv_vec<'a>(
&'a self,
element_limit: usize,
vec: &'a mut Vec<T>,
) -> impl Future<Output = ()> + 'a
pub fn recv_vec<'a>( &'a self, element_limit: usize, vec: &'a mut Vec<T>, ) -> impl Future<Output = ()> + 'a
Wait for up to element_limit
values from the channel and
store them in vec
.
vec
should be empty when passed in. Nevertheless, recv_vec
will clear it before adding values. The intent of recv_vec
is that batches can be repeatedly read by workers without new
allocations.
It’s not required, but vec
’s capacity should be greater than
or equal to element_limit to avoid reallocation.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Receiver<T>
impl<T> RefUnwindSafe for Receiver<T>
impl<T> Send for Receiver<T>where
T: Send,
impl<T> Sync for Receiver<T>where
T: Send,
impl<T> !Unpin for Receiver<T>
impl<T> UnwindSafe for Receiver<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more