pub struct Sender<T: Send> { /* private fields */ }Expand description
The send end of a channel.
Cloneable (MPMC): each clone shares the same internal channel.
When the last Sender is dropped, waiting receivers are woken with
ChannelError::Disconnected.
Implementations§
Source§impl<T: Send> Sender<T>
impl<T: Send> Sender<T>
Sourcepub fn send(&self, msg: T) -> Result<(), ChannelError>
pub fn send(&self, msg: T) -> Result<(), ChannelError>
Send a message, blocking until buffer space is available.
Returns Ok(()) on success, or Err(ChannelError::Disconnected)
if all receivers have been dropped before or during the send.
Sourcepub fn try_send(&self, msg: T) -> Result<(), (T, ChannelError)>
pub fn try_send(&self, msg: T) -> Result<(), (T, ChannelError)>
Try to send without blocking.
Returns Err((msg, WouldBlock)) if the buffer is full, or
Err((msg, Disconnected)) if all receivers are gone.
Sourcepub fn is_disconnected(&self) -> bool
pub fn is_disconnected(&self) -> bool
Returns true if all receivers have been dropped.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Sender<T>
impl<T> !RefUnwindSafe for Sender<T>
impl<T> Send for Sender<T>
impl<T> Sync for Sender<T>
impl<T> Unpin for Sender<T>
impl<T> UnsafeUnpin 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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more