Struct batch_channel::Sender
source · pub struct Sender<T> { /* private fields */ }Expand description
The asynchronous sending half of a channel.
Implementations§
source§impl<T> Sender<T>
impl<T> Sender<T>
sourcepub fn into_sync(self) -> SyncSender<T>
pub fn into_sync(self) -> SyncSender<T>
Converts asynchronous Sender to SyncSender.
sourcepub fn send(
&self,
value: T,
) -> impl Future<Output = Result<(), SendError<T>>> + '_
pub fn send( &self, value: T, ) -> impl Future<Output = Result<(), SendError<T>>> + '_
Send a single value.
Returns SendError if all receivers are dropped.
sourcepub fn send_iter<'a, I>(
&'a self,
values: I,
) -> impl Future<Output = Result<(), SendError<()>>> + 'awhere
I: IntoIterator<Item = T> + 'a,
pub fn send_iter<'a, I>(
&'a self,
values: I,
) -> impl Future<Output = Result<(), SendError<()>>> + 'awhere
I: IntoIterator<Item = T> + 'a,
Send multiple values.
If all receivers are dropped, SendError is returned and unsent values are dropped.
sourcepub async fn autobatch<F, R>(
self,
batch_limit: usize,
f: F,
) -> Result<R, SendError<()>>
pub async fn autobatch<F, R>( self, batch_limit: usize, f: F, ) -> Result<R, SendError<()>>
Automatically accumulate sends into a buffer of size batch_limit
and send when full.
The callback’s future must be boxed to work around type system limitations in Rust.
sourcepub async fn autobatch_or_cancel<F>(self, capacity: usize, f: F)
pub async fn autobatch_or_cancel<F>(self, capacity: usize, f: F)
Same as Sender::autobatch except that it immediately returns
() when f returns SendError. This is a convenience wrapper
for the common case that the future is passed to a spawn
function and the receiver being dropped (i.e. SendError) is
considered a clean cancellation.
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
Mutably borrows from an owned value. Read more
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)
🔬This is a nightly-only experimental API. (
clone_to_uninit)