pub struct Receiver<T> { /* private fields */ }Expand description
Receiver half of a mailbox.
Dropping the receiver closes the mailbox but does not drain buffered messages. Messages already in ready or overflow, or racing through an in-flight enqueue, remain owned by shared mailbox state until the last sender is dropped.
Dropping the last sender disconnects the mailbox, but the receiver continues returning buffered messages until ready and overflow are empty.
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>
Receive the next message.
Returns None after all senders are dropped and all buffered messages
have been drained.
Sourcepub fn try_recv(&mut self) -> Result<T, TryRecvError>
pub fn try_recv(&mut self) -> Result<T, TryRecvError>
Try to receive the next message without waiting.
Returns TryRecvError::Disconnected after all senders are dropped and
all buffered messages have been drained.
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> UnsafeUnpin 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