pub struct Sender<T>(/* private fields */);Expand description
The transmitting end of a channel.
Use unbounded, bounded or rendezvous to create a channel.
Implementations§
Source§impl<T> Sender<T>
impl<T> Sender<T>
Sourcepub async fn send(&self, msg: T) -> Result<(), ChannelError>
pub async fn send(&self, msg: T) -> Result<(), ChannelError>
Send a value into the channel.
Waits until there is space in the channel buffer.
Returns an error if all receivers have been dropped.
Sourcepub async fn send_deadline(
&self,
msg: T,
deadline: impl Into<Deadline>,
) -> Result<(), ChannelError>
pub async fn send_deadline( &self, msg: T, deadline: impl Into<Deadline>, ) -> Result<(), ChannelError>
Send a value into the channel.
Waits until there is space in the channel buffer or the deadline is reached.
Returns an error if all receivers have been dropped or the deadline is reached. The msg is lost in case of timeout.
Sourcepub fn send_blocking(&self, msg: T) -> Result<(), ChannelError>
pub fn send_blocking(&self, msg: T) -> Result<(), ChannelError>
Send a value into the channel.
Blocks until there is space in the channel buffer.
Returns an error if all receivers have been dropped.
Sourcepub fn send_deadline_blocking(
&self,
msg: T,
deadline: impl Into<Deadline>,
) -> Result<(), ChannelError>
pub fn send_deadline_blocking( &self, msg: T, deadline: impl Into<Deadline>, ) -> Result<(), ChannelError>
Send a value into the channel.
Blocks until there is space in the channel buffer or the deadline is reached.
Returns an error if all receivers have been dropped or the deadline is reached. The msg is lost in case of timeout.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Gets if the channel has no pending messages.
Note that rendezvous channels are always empty.
Trait Implementations§
Auto 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,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> FsChangeNote for T
impl<T> FsChangeNote for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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>
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