pub struct MRx<T>(/* private fields */);
Expand description
Multi-consumer (receiver) that works in blocking context.
Inherits 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>
Receive message, will block when channel is empty.
Returns Ok(T) when successful.
Returns Err(RecvError) when all Tx dropped.
Sourcepub fn try_recv(&self) -> Result<T, TryRecvError>
pub fn try_recv(&self) -> Result<T, TryRecvError>
Try to receive message, non-blocking.
Returns Ok(T) when successful.
Returns Err(TryRecvError::Empty) when channel is empty.
returns Err(TryRecvError::Disconnected) when all Tx dropped and channel is empty.
Sourcepub fn recv_timeout(&self, duration: Duration) -> Result<T, RecvTimeoutError>
pub fn recv_timeout(&self, duration: Duration) -> Result<T, RecvTimeoutError>
Waits for a message to be received from the channel, but only for a limited time. Will block when channel is empty.
The behavior is atomic, either successfully polls a message, or operation cancelled due to 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) when all Tx dropped and channel is empty.