pub struct Sender<T> { /* private fields */ }
Expand description
A transmitting end of a channel.
Implementations§
source§impl<T> Sender<T>
impl<T> Sender<T>
sourcepub fn send_async(&self, item: T) -> SendFut<'_, T> ⓘ
pub fn send_async(&self, item: T) -> SendFut<'_, T> ⓘ
Asynchronously send a value into the channel, returning an error if all receivers have been dropped. If the channel is bounded and is full, the returned future will yield to the async runtime.
In the current implementation, the returned future will not yield to the async runtime if the channel is unbounded. This may change in later versions.
sourcepub fn into_send_async(self, item: T) -> SendFut<'static, T> ⓘ
pub fn into_send_async(self, item: T) -> SendFut<'static, T> ⓘ
Convert this sender into a future that asynchronously sends a single message into the channel, returning an error if all receivers have been dropped. If the channel is bounded and is full, this future will yield to the async runtime.
In the current implementation, the returned future will not yield to the async runtime if the channel is unbounded. This may change in later versions.
sourcepub fn sink(&self) -> SendSink<'_, T>
pub fn sink(&self) -> SendSink<'_, T>
Create an asynchronous sink that uses this sender to asynchronously send messages into the channel. The sender will continue to be usable after the sink has been dropped.
In the current implementation, the returned sink will not yield to the async runtime if the channel is unbounded. This may change in later versions.
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>>
Attempt to send a value into the channel. If the channel is bounded and full, or all
receivers have been dropped, an error is returned. If the channel associated with this
sender is unbounded, this method has the same behaviour as Sender::send
.
sourcepub fn send(&self, msg: T) -> Result<(), SendError<T>>
pub fn send(&self, msg: T) -> Result<(), SendError<T>>
Send a value into the channel, returning an error if all receivers have been dropped. If the channel is bounded and is full, this method will block until space is available or all receivers have been dropped. If the channel is unbounded, this method will not block.
sourcepub fn send_deadline(
&self,
msg: T,
deadline: Instant,
) -> Result<(), SendTimeoutError<T>>
pub fn send_deadline( &self, msg: T, deadline: Instant, ) -> Result<(), SendTimeoutError<T>>
Send a value into the channel, returning an error if all receivers have been dropped or the deadline has passed. If the channel is bounded and is full, this method will block until space is available, the deadline is reached, or all receivers have been dropped.
sourcepub fn send_timeout(
&self,
msg: T,
dur: Duration,
) -> Result<(), SendTimeoutError<T>>
pub fn send_timeout( &self, msg: T, dur: Duration, ) -> Result<(), SendTimeoutError<T>>
Send a value into the channel, returning an error if all receivers have been dropped or the timeout has expired. If the channel is bounded and is full, this method will block until space is available, the timeout has expired, or all receivers have been dropped.
sourcepub fn is_disconnected(&self) -> bool
pub fn is_disconnected(&self) -> bool
Returns true if all receivers for this channel have been dropped.
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.
Trait Implementations§
source§impl<T> Clone for Sender<T>
impl<T> Clone for Sender<T>
source§fn clone(&self) -> Self
fn clone(&self) -> Self
Clone this sender. Sender
acts as a handle to the ending a channel. Remaining channel
contents will only be cleaned up when all senders and the receiver have been dropped.
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl<T> Freeze for Sender<T>
impl<T> RefUnwindSafe for Sender<T>
impl<T> Send for Sender<T>where
T: Send,
impl<T> Sync for Sender<T>where
T: Send,
impl<T> Unpin for Sender<T>
impl<T> UnwindSafe for Sender<T>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)