BlockingRxTrait

Trait BlockingRxTrait 

Source
pub trait BlockingRxTrait<T: Send + 'static>:
    Send
    + 'static
    + Debug
    + Display
    + AsRef<ChannelShared<T>> {
    // 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 clone_to_vec(self, count: usize) -> Vec<Self>
       where Self: Sized;

    // Provided methods
    fn len(&self) -> usize { ... }
    fn capacity(&self) -> Option<usize> { ... }
    fn is_empty(&self) -> bool { ... }
    fn is_full(&self) -> bool { ... }
    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>

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.

Source

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.

Source

fn recv_timeout(&self, timeout: Duration) -> Result<T, RecvTimeoutError>

Receives a message from the channel with a timeout. 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) if the sender has been dropped and the channel is empty.

Source

fn clone_to_vec(self, count: usize) -> Vec<Self>
where Self: Sized,

Provided Methods§

Source

fn len(&self) -> usize

The number of messages in the channel at the moment

Source

fn capacity(&self) -> Option<usize>

The capacity of the channel, return None for unbounded channel.

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

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>