pub struct MRx<T>(/* private fields */);
Expand description
A multi-consumer (receiver) that works in a blocking context.
Inherits from Rx<T>
and implements Clone
.
Additional methods can be accessed through Deref<Target=[ChannelShared]>
.
You can use into()
to convert it to Rx<T>
.
Methods from Deref<Target = Rx<T>>§
Sourcepub fn recv<'a>(&'a self) -> Result<T, RecvError>
pub fn recv<'a>(&'a self) -> Result<T, RecvError>
Receives a message from the channel. This method will block until a message is received or the channel is closed.
Returns Ok(T)
on success.
Returns Err(RecvError) if the sender has been dropped.
Sourcepub fn try_recv(&self) -> Result<T, TryRecvError>
pub fn try_recv(&self) -> Result<T, TryRecvError>
Attempts to receive a message from the channel without blocking.
Returns Ok(T)
when successful.
Returns Err(TryRecvError::Empty) if the channel is empty.
Returns Err(TryRecvError::Disconnected) if the sender has been dropped and the channel is empty.
Sourcepub fn recv_timeout(&self, timeout: Duration) -> Result<T, RecvTimeoutError>
pub fn recv_timeout(&self, timeout: Duration) -> Result<T, RecvTimeoutError>
Receives a message from the channel with a timeout. Will block when channel is empty.
The behavior is atomic: the message is either received successfully or the operation is canceled due to a timeout.
Returns Ok(T)
when successful.
Returns Err(RecvTimeoutError::Timeout) when a message could not be received because the channel is empty and the operation timed out.
Returns Err(RecvTimeoutError::Disconnected) if the sender has been dropped and the channel is empty.