pub struct MAsyncTx<T>(/* private fields */);
Expand description
Multi-producer (sender) that works in async context.
Inherits AsyncTx<T>
and implements Clone.
Additional methods can be accessed through Deref<Target=ChannelShared>.
You can use into()
to convert it to AsyncTx<T>
.
MAsyncTx
can be converted into MTx
via From
trait,
that means you can have two types of senders both within async and
blocking context to the same channel.
Implementations§
Methods from Deref<Target = AsyncTx<T>>§
Sourcepub fn try_send(&self, item: T) -> Result<(), TrySendError<T>>
pub fn try_send(&self, item: T) -> Result<(), TrySendError<T>>
Try to send message, non-blocking
Returns Ok(())
when successful.
Returns Err(TrySendError::Full) on channel full for bounded channel.
Returns Err(TrySendError::Disconnected) when all Rx dropped.
Sourcepub fn send<'a>(&'a self, item: T) -> SendFuture<'a, T> ⓘ
pub fn send<'a>(&'a self, item: T) -> SendFuture<'a, T> ⓘ
Send message. Will await when channel is full.
Returns Ok(())
on successful.
Returns Err(SendError) when all Rx is dropped.
Sourcepub fn make_send_future<'a>(&'a self, item: T) -> SendFuture<'a, T> ⓘ
👎Deprecated
pub fn make_send_future<'a>(&'a self, item: T) -> SendFuture<'a, T> ⓘ
Use send() instead
Sourcepub fn send_timeout<'a>(
&'a self,
item: T,
duration: Duration,
) -> SendTimeoutFuture<'a, T> ⓘ
Available on crate features tokio
or async_std
only.
pub fn send_timeout<'a>( &'a self, item: T, duration: Duration, ) -> SendTimeoutFuture<'a, T> ⓘ
tokio
or async_std
only.Waits for a message to be sent into the channel, but only for a limited time. Will await when channel is full.
The behavior is atomic, either message sent successfully or returned on error.
Returns Ok(())
when successful.
Returns Err(SendTimeoutError::Timeout) when the operation timed out.
Returns Err(SendTimeoutError::Disconnected) when all Rx dropped.
Methods from Deref<Target = ChannelShared>§
Trait Implementations§
Source§fn as_ref(&self) -> &ChannelShared
fn as_ref(&self) -> &ChannelShared
Source§impl<T: Unpin + Send + 'static> AsyncTxTrait<T> for MAsyncTx<T>
impl<T: Unpin + Send + 'static> AsyncTxTrait<T> for MAsyncTx<T>
Source§fn try_send(&self, item: T) -> Result<(), TrySendError<T>>
fn try_send(&self, item: T) -> Result<(), TrySendError<T>>
Source§fn send<'a>(&'a self, item: T) -> SendFuture<'a, T> ⓘ
fn send<'a>(&'a self, item: T) -> SendFuture<'a, T> ⓘ
Source§fn send_timeout<'a>(
&'a self,
item: T,
duration: Duration,
) -> SendTimeoutFuture<'a, T> ⓘ
fn send_timeout<'a>( &'a self, item: T, duration: Duration, ) -> SendTimeoutFuture<'a, T> ⓘ
tokio
or async_std
only.