pub trait BlockingRxTrait<T: Send + 'static>:
Send
+ 'static
+ Debug
+ Display
+ AsRef<ChannelShared> {
// Required methods
fn recv<'a>(&'a self) -> Result<T, RecvError>;
fn try_recv(&self) -> Result<T, TryRecvError>;
fn recv_timeout(&self, timeout: Duration) -> Result<T, RecvTimeoutError>;
fn len(&self) -> usize;
fn is_empty(&self) -> bool;
fn is_full(&self) -> bool;
// Provided method
fn is_disconnected(&self) -> bool { ... }
}Expand description
For writing generic code with MRx & Rx
Required Methods§
Sourcefn recv<'a>(&'a self) -> Result<T, RecvError>
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.
Sourcefn try_recv(&self) -> Result<T, TryRecvError>
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.
Sourcefn recv_timeout(&self, timeout: Duration) -> Result<T, RecvTimeoutError>
fn recv_timeout(&self, timeout: 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.
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.
Provided Methods§
Sourcefn is_disconnected(&self) -> bool
fn is_disconnected(&self) -> bool
Return true if the other side has closed