MTx

Struct MTx 

Source
pub struct MTx<T>(/* private fields */);
Expand description

A multi-producer (sender) that works in a blocking context.

Inherits from Tx<T> and implements Clone. Additional methods can be accessed through Deref<Target=[ChannelShared]>.

You can use into() to convert it to Tx<T>.

Methods from Deref<Target = Tx<T>>§

Source

pub 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

pub 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

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

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

The behavior is atomic: the message is either sent successfully or returned on error.

Returns Ok(()) when successful.

Returns Err(SendTimeoutError::Timeout) if the operation timed out.

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

Methods from Deref<Target = ChannelShared<T>>§

Source

pub fn len(&self) -> usize

The number of messages in the channel.

Source

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

The capacity of the channel. Returns None for unbounded channels.

Source

pub fn is_empty(&self) -> bool

Returns true if the channel is empty.

Source

pub fn is_full(&self) -> bool

Returns true if the channel is full.

Source

pub fn is_disconnected(&self) -> bool

Returns true if all senders or receivers have been dropped.

Source

pub fn get_tx_count(&self) -> usize

Returns the number of senders for the channel.

Source

pub fn get_rx_count(&self) -> usize

Returns the number of receivers for the channel.

Source

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

Returns the number of wakers for senders and receivers. For debugging purposes.

Trait Implementations§

Source§

impl<T> AsRef<ChannelShared<T>> for MTx<T>

Source§

fn as_ref(&self) -> &ChannelShared<T>

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<T: Send + 'static> BlockingTxTrait<T> for MTx<T>

Source§

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

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. Read more
Source§

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

Attempts to send a message without blocking. Read more
Source§

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

Sends a message with a timeout. Will block when channel is empty. Read more
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§

impl<T> Clone for MTx<T>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T> Debug for MTx<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> Deref for MTx<T>

Source§

fn deref(&self) -> &Self::Target

Inherits all the functions of Tx.

Source§

type Target = Tx<T>

The resulting type after dereferencing.
Source§

impl<T> Display for MTx<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> From<MAsyncTx<T>> for MTx<T>

Source§

fn from(value: MAsyncTx<T>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<MTx<T>> for MAsyncTx<T>

Source§

fn from(value: MTx<T>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<MTx<T>> for Tx<T>

Source§

fn from(tx: MTx<T>) -> Self

Converts to this type from the input type.
Source§

impl<T: Send> Sync for MTx<T>

Auto Trait Implementations§

§

impl<T> !Freeze for MTx<T>

§

impl<T> !RefUnwindSafe for MTx<T>

§

impl<T> Send for MTx<T>
where T: Send,

§

impl<T> Unpin for MTx<T>

§

impl<T> !UnwindSafe for MTx<T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.