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,
impl<T, P> Sender<T, P>where
P: Ord,
Sourcepub fn try_send(&self, msg: T, priority: P) -> Result<(), TrySendError<(T, P)>>
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.
Sourcepub fn try_sendv<I>(
&self,
msgs: Peekable<I>,
) -> Result<(), TrySendError<Peekable<I>>>
pub fn try_sendv<I>( &self, msgs: Peekable<I>, ) -> Result<(), TrySendError<Peekable<I>>>
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.
Sourcepub async fn send(&self, msg: T, priority: P) -> Result<(), SendError<(T, P)>>
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.
Sourcepub async fn sendv<I>(
&self,
msgs: Peekable<I>,
) -> Result<(), SendError<Peekable<I>>>
pub async fn sendv<I>( &self, msgs: Peekable<I>, ) -> Result<(), SendError<Peekable<I>>>
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.
Sourcepub fn close(&self) -> bool
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.
Sourcepub fn receiver_count(&self) -> usize
pub fn receiver_count(&self) -> usize
Returns the number of receivers for the channel.
Sourcepub fn sender_count(&self) -> usize
pub fn sender_count(&self) -> usize
Returns the number of senders for the channel.