pub struct Receiver<T> { /* private fields */ }
Expand description
Receives messages sent by Sender.
Implementations§
Source§impl<T> Receiver<T>
impl<T> Receiver<T>
Sourcepub fn close_all(&self)
pub fn close_all(&self)
Disconnects all receivers from senders. The receivers will still receive all buffered or reserved messages before returning an error, allowing a graceful teardown.
Sourcepub async fn recv(&self) -> Result<T, RecvError>
pub async fn recv(&self) -> Result<T, RecvError>
Waits until there’s a message to be read and returns. Returns an error when there are no more messages in the queue and all Senders have been dropped.
Sourcepub fn try_recv(&self) -> Result<T, TryRecvError>
pub fn try_recv(&self) -> Result<T, TryRecvError>
Checks if there’s a message to be read and returns immediately. Returns an error when the channel is disconnected or empty.
pub async fn recv_many( &self, vec: &mut Vec<T>, count: usize, ) -> Result<usize, RecvError>
pub fn try_recv_many( &self, vec: &mut Vec<T>, count: usize, ) -> Result<usize, TryRecvError>
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