pub struct Receiver<T: Send> { /* private fields */ }Expand description
The receive end of a channel.
Cloneable (MPMC): each clone shares the same internal channel.
When the last Receiver is dropped, waiting senders are woken with
ChannelError::Disconnected.
Implementations§
Source§impl<T: Send> Receiver<T>
impl<T: Send> Receiver<T>
Sourcepub fn recv(&self) -> Result<T, ChannelError>
pub fn recv(&self) -> Result<T, ChannelError>
Receive a message, blocking until one is available.
Returns Ok(msg) on success. Returns Err(ChannelError::Disconnected)
if all senders have been dropped and the buffer is empty.
Sourcepub fn try_recv(&self) -> Result<T, ChannelError>
pub fn try_recv(&self) -> Result<T, ChannelError>
Try to receive without blocking.
Returns Err(WouldBlock) if the buffer is empty, or
Err(Disconnected) if all senders are gone and the buffer is empty.
Sourcepub fn is_disconnected(&self) -> bool
pub fn is_disconnected(&self) -> bool
Returns true if all senders have been dropped.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Receiver<T>
impl<T> !RefUnwindSafe for Receiver<T>
impl<T> Send for Receiver<T>
impl<T> Sync for Receiver<T>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more