pub struct Sender<T> {
flavor: SenderFlavor<T>,
}
Expand description
The sending side of a channel.
Fields§
§flavor: SenderFlavor<T>
Implementations§
source§impl<T> Sender<T>
impl<T> Sender<T>
sourcepub fn try_send(&self, msg: T) -> Result<(), TrySendError<T>>
pub fn try_send(&self, msg: T) -> Result<(), TrySendError<T>>
Attempts to send a message into the channel without blocking.
This method will either send a message into the channel immediately or return an error if the channel is full or disconnected. The returned error contains the original message.
If called on a zero-capacity channel, this method will send the message only if there happens to be a receive operation on the other side of the channel at the same time.
sourcepub fn send(&self, msg: T) -> Result<(), SendError<T>>
pub fn send(&self, msg: T) -> Result<(), SendError<T>>
Blocks the current thread until a message is sent or the channel is disconnected.
If the channel is full and not disconnected, this call will block until the send operation can proceed. If the channel becomes disconnected, this call will wake up and return an error. The returned error contains the original message.
If called on a zero-capacity channel, this method will wait for a receive operation to appear on the other side of the channel.
source§impl<T> Sender<T>
impl<T> Sender<T>
sourcepub fn send_timeout(
&self,
msg: T,
timeout: Duration
) -> Result<(), SendTimeoutError<T>>
pub fn send_timeout( &self, msg: T, timeout: Duration ) -> Result<(), SendTimeoutError<T>>
Waits for a message to be sent into the channel, but only for a limited time.
If the channel is full and not disconnected, this call will block until the send operation can proceed or the operation times out. If the channel becomes disconnected, this call will wake up and return an error. The returned error contains the original message.
If called on a zero-capacity channel, this method will wait for a receive operation to appear on the other side of the channel.
sourcepub fn send_deadline(
&self,
msg: T,
deadline: Instant
) -> Result<(), SendTimeoutError<T>>
pub fn send_deadline( &self, msg: T, deadline: Instant ) -> Result<(), SendTimeoutError<T>>
Waits for a message to be sent into the channel, but only until a given deadline.
If the channel is full and not disconnected, this call will block until the send operation can proceed or the operation times out. If the channel becomes disconnected, this call will wake up and return an error. The returned error contains the original message.
If called on a zero-capacity channel, this method will wait for a receive operation to appear on the other side of the channel.
sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true
if the channel is empty.
Note: Zero-capacity channels are always empty.
sourcepub fn is_full(&self) -> bool
pub fn is_full(&self) -> bool
Returns true
if the channel is full.
Note: Zero-capacity channels are always full.
sourcepub fn same_channel(&self, other: &Sender<T>) -> bool
pub fn same_channel(&self, other: &Sender<T>) -> bool
Returns true
if senders belong to the same channel.