Struct Sender

Source
pub struct Sender<I, P>
where P: Ord,
{ /* private fields */ }
Expand description

Send side of the channel. Can be cloned.

Implementations§

Source§

impl<T, P> Sender<T, P>
where P: Ord,

Source

pub fn try_send(&self, msg: T, priority: P) -> Result<(), TrySendError<(T, P)>>

Attempts to send a message into the channel.

If the channel is full or closed, this method returns an error.

Source

pub fn try_sendv<I>( &self, msgs: Peekable<I>, ) -> Result<(), TrySendError<Peekable<I>>>
where I: Iterator<Item = (T, P)>,

Attempts to send multiple messages into the channel.

If the channel is closed, this method returns an error.

If the channel is full or nearly full, this method inserts as many messages as it can into the channel and then returns an error containing the remaining unsent messages.

Source

pub async fn send(&self, msg: T, priority: P) -> Result<(), SendError<(T, P)>>

Sends a message into the channel.

If the channel is full, this method waits until there is space for a message.

If the channel is closed, this method returns an error.

Source

pub async fn sendv<I>( &self, msgs: Peekable<I>, ) -> Result<(), SendError<Peekable<I>>>
where I: Iterator<Item = (T, P)>,

Send multiple messages into the channel

If the channel is full, this method waits until there is space.

If the channel is closed, this method returns an error.

Source

pub fn close(&self) -> bool

Closes the channel and notifies all blocked operations.

Returns true if this call has closed the channel and it was not closed already.

Source

pub fn is_closed(&self) -> bool

Returns true if the channel is closed

Source

pub fn is_empty(&self) -> bool

Return true if the channel is empty

Source

pub fn is_full(&self) -> bool

Return true if the channel is full

Source

pub fn len(&self) -> u64

Returns the number of messages in the channel.

Source

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

Returns the channel capacity if it’s bounded.

Source

pub fn receiver_count(&self) -> usize

Returns the number of receivers for the channel.

Source

pub fn sender_count(&self) -> usize

Returns the number of senders for the channel.

Trait Implementations§

Source§

impl<I, P> Clone for Sender<I, P>
where P: Ord,

Source§

fn clone(&self) -> Sender<I, P>

Returns a copy 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<I: Debug, P> Debug for Sender<I, P>
where P: Ord + Debug,

Source§

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

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

impl<I, P> Drop for Sender<I, P>
where P: Ord,

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<I, P> Freeze for Sender<I, P>

§

impl<I, P> RefUnwindSafe for Sender<I, P>

§

impl<I, P> Send for Sender<I, P>
where I: Send, P: Send,

§

impl<I, P> Sync for Sender<I, P>
where I: Send, P: Send,

§

impl<I, P> Unpin for Sender<I, P>

§

impl<I, P> UnwindSafe for Sender<I, P>

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> 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, 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.