Trait BlockingRxTrait

Source
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§

Source

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.

Source

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.

Source

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.

Source

fn len(&self) -> usize

The number of messages in the channel at the moment

Source

fn is_empty(&self) -> bool

Whether channel is empty at the moment

Source

fn is_full(&self) -> bool

Whether the channel is full at the moment

Provided Methods§

Source

fn is_disconnected(&self) -> bool

Return true if the other side has closed

Implementors§

Source§

impl<T: Send + 'static> BlockingRxTrait<T> for MRx<T>

Source§

impl<T: Send + 'static> BlockingRxTrait<T> for Rx<T>