pub struct Receiver<T> { /* private fields */ }
Expand description
The receiving half of the channel.
This half can be used to receive values from the channel. It can be cloned to receive from multiple tasks.
Implementations§
Source§impl<T> Receiver<T>
impl<T> Receiver<T>
Sourcepub async fn recv(&self) -> ChannelResult<Option<T>>
pub async fn recv(&self) -> ChannelResult<Option<T>>
Receives a message from the channel.
If the channel is empty, the calling task will be suspended until an item becomes available or the channel is closed.
§Returns
Ok(Some(value))
if a message was successfully received.
Ok(None)
if the channel is closed and empty.
Err(ChannelError::ChannelClosed)
if the channel was closed while waiting but not empty.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Gets the current number of elements in the channel.
§Returns
The number of elements currently in the channel.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Checks if the channel is currently empty.
§Returns
true
if the channel contains no elements, false
otherwise.
Sourcepub fn is_full(&self) -> bool
pub fn is_full(&self) -> bool
Checks if the channel is currently full.
§Returns
true
if the number of elements equals the capacity, false
otherwise.
Sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
Returns the current capacity of the channel.
§Returns
The current number of elements in the channel.
Sourcepub fn max_capacity(&self) -> usize
pub fn max_capacity(&self) -> usize
Returns the maximum buffer capacity of the channel.
§Returns
The maximum number of elements the channel can hold.