pub struct Receiver<T> { /* private fields */ }Expand description
Implementations§
Source§impl<T> Receiver<T>
impl<T> Receiver<T>
Sourcepub async fn recv(&mut self) -> Option<T>
pub async fn recv(&mut self) -> Option<T>
Receives the next value, waiting for one if the channel is open
and empty. Answers None once the channel is closed and drained
(no sender, and no reserved slot still to be used).
Cancel safe: a dropped future loses no value.
Sourcepub async fn recv_many(&mut self, buf: &mut Vec<T>, limit: usize) -> usize
pub async fn recv_many(&mut self, buf: &mut Vec<T>, limit: usize) -> usize
Receives up to limit values into buf and answers how many,
waiting for at least one. Answers 0 when limit is 0 or the
channel ended.
Cancel safe: a dropped future loses no value.
Sourcepub fn poll_recv(&mut self, cx: &mut Context<'_>) -> Poll<Option<T>>
pub fn poll_recv(&mut self, cx: &mut Context<'_>) -> Poll<Option<T>>
Polls to receive the next value; the waker of cx is woken when
a value arrives or the channel ends.
Sourcepub fn poll_recv_many(
&mut self,
cx: &mut Context<'_>,
buf: &mut Vec<T>,
limit: usize,
) -> Poll<usize>
pub fn poll_recv_many( &mut self, cx: &mut Context<'_>, buf: &mut Vec<T>, limit: usize, ) -> Poll<usize>
Polls to receive up to limit values into buf; see
recv_many.
Sourcepub fn try_recv(&mut self) -> Result<T, TryRecvError>
pub fn try_recv(&mut self) -> Result<T, TryRecvError>
Receives the next value without waiting.
§Errors
TryRecvError::Empty
if a value may yet come,
TryRecvError::Disconnected
if the channel ended.
Sourcepub fn close(&mut self)
pub fn close(&mut self)
Closes the receiving half without dropping it: no further value can be sent, and sends that wait fail. The values already buffered, and the slots reserved before the close, stay usable.
Sourcepub fn is_closed(&self) -> bool
pub fn is_closed(&self) -> bool
Whether the channel is closed: close was called,
or every sender is gone. Buffered values may still be received.
Sourcepub fn max_capacity(&self) -> usize
pub fn max_capacity(&self) -> usize
The channel’s maximum capacity: the buffer it was created with.