Skip to main content

BlockingTxTrait

Trait BlockingTxTrait 

Source
pub trait BlockingTxTrait<T: Send + 'static>:
    Send
    + 'static
    + Debug
    + Display {
    // Required methods
    fn send(&self, _item: T) -> Result<(), SendError<T>>;
    fn try_send(&self, _item: T) -> Result<(), TrySendError<T>>;
    fn send_timeout(
        &self,
        item: T,
        timeout: Duration,
    ) -> Result<(), SendTimeoutError<T>>;
    fn len(&self) -> usize;
    fn capacity(&self) -> Option<usize>;
    fn is_empty(&self) -> bool;
    fn is_full(&self) -> bool;
    fn is_disconnected(&self) -> bool;
    fn get_tx_count(&self) -> usize;
    fn get_rx_count(&self) -> usize;
    fn clone_to_vec(self, count: usize) -> Vec<Self>
       where Self: Sized;
    fn get_wakers_count(&self) -> (usize, usize);
}
Expand description

For writing generic code with MTx & Tx

Required Methods§

Source

fn send(&self, _item: T) -> Result<(), SendError<T>>

Sends a message. This method will block until the message is sent or the channel is closed.

Returns Ok(()) on success.

Returns Err(SendError) if the receiver has been dropped.

Source

fn try_send(&self, _item: T) -> Result<(), TrySendError<T>>

Attempts to send a message without blocking.

Returns Ok(()) when successful.

Returns Err([TrySendError::Full]) if the channel is full.

Returns Err(TrySendError::Disconnected) if the receiver has been dropped.

Source

fn send_timeout( &self, item: T, timeout: Duration, ) -> Result<(), SendTimeoutError<T>>

Sends a message with a timeout. Will block when channel is empty.

Returns Ok(()) when successful.

Returns Err(SendTimeoutError::Timeout) if the message could not be sent because the channel is full and the operation timed out.

Returns Err(SendTimeoutError::Disconnected) if the receiver has been dropped.

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

Source

fn get_tx_count(&self) -> usize

Return the number of senders

Source

fn get_rx_count(&self) -> usize

Return the number of receivers

Source

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

Source

fn get_wakers_count(&self) -> (usize, usize)

Implementors§

Source§

impl<F: Flavor + FlavorMP> BlockingTxTrait<<F as Queue>::Item> for MTx<F>
where F::Item: Send + 'static,

Source§

impl<F: Flavor> BlockingTxTrait<<F as Queue>::Item> for Tx<F>
where F::Item: Send + 'static,