MRx

Struct MRx 

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

Multi-consumer (receiver) that works in blocking context.

Inherits Rx<T> and implements Clone. Additional methods can be accessed through Deref<Target=ChannelShared>.

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

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

Source

pub 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

pub 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

pub fn recv_timeout(&self, duration: 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.

The behavior is atomic, either successfully polls a message, or operation cancelled due to timeout.

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

pub fn len(&self) -> usize

The number of messages in the channel at the moment

Source

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

The capacity of the channel

Source

pub fn is_empty(&self) -> bool

Whether channel is empty at the moment

Source

pub fn is_full(&self) -> bool

Whether the channel is full at the moment

Methods from Deref<Target = ChannelShared>§

Source

pub fn is_disconnected(&self) -> bool

Return true if all the senders or receivers are dropped

Source

pub fn get_tx_count(&self) -> usize

Get the count of alive senders

Source

pub fn get_rx_count(&self) -> usize

Get the count of alive receivers

Source

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

Just for debugging purpose, to monitor queue size

Trait Implementations§

Source§

impl<T> AsRef<ChannelShared> for MRx<T>

Source§

fn as_ref(&self) -> &ChannelShared

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

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

Source§

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

Source§

fn recv<'a>(&'a self) -> Result<T, RecvError>

Receive message, will block when channel is empty. Read more
Source§

fn try_recv(&self) -> Result<T, TryRecvError>

Try to receive message, non-blocking. Read more
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. 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, None for unbounded.
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 MRx<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 MRx<T>

Source§

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

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

impl<T> Deref for MRx<T>

Source§

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

inherit all the functions of Rx

Source§

type Target = Rx<T>

The resulting type after dereferencing.
Source§

impl<T> Display for MRx<T>

Source§

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

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

impl<T> From<MAsyncRx<T>> for MRx<T>

Source§

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

Converts to this type from the input type.
Source§

impl<T> From<MRx<T>> for Rx<T>

Source§

fn from(rx: MRx<T>) -> Self

Converts to this type from the input type.
Source§

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

Auto Trait Implementations§

§

impl<T> Freeze for MRx<T>

§

impl<T> !RefUnwindSafe for MRx<T>

§

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

§

impl<T> Unpin for MRx<T>
where T: Unpin,

§

impl<T> !UnwindSafe for MRx<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<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.