Struct batch_channel::BoundedSender
source · pub struct BoundedSender<T> { /* private fields */ }Expand description
The sending half of a bounded channel.
Implementations§
source§impl<T: 'static> BoundedSender<T>
impl<T: 'static> BoundedSender<T>
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, the values are returned in SendError untouched. Either the entire batch is sent or none of it is sent.
sourcepub async fn autobatch<F, R>(
self,
capacity: usize,
f: F
) -> Result<R, SendError<()>>where
for<'a> F: FnOnce(&'a mut BoundedBatchSender<T>) -> BoxFuture<'a, Result<R, SendError<()>>>,
pub async fn autobatch<F, R>( self, capacity: usize, f: F ) -> Result<R, SendError<()>>where for<'a> F: FnOnce(&'a mut BoundedBatchSender<T>) -> BoxFuture<'a, Result<R, SendError<()>>>,
Automatically accumulate sends into a buffer of size batch
and send when full.
The callback’s future must be boxed to work around type system limitations in Rust.
TODO: add a feature that gates this only dependency on futures crate.
Trait Implementations§
source§impl<T: Debug> Debug for BoundedSender<T>
impl<T: Debug> Debug for BoundedSender<T>
Auto Trait Implementations§
impl<T> RefUnwindSafe for BoundedSender<T>
impl<T> Send for BoundedSender<T>where T: Send,
impl<T> Sync for BoundedSender<T>where T: Send,
impl<T> Unpin for BoundedSender<T>
impl<T> UnwindSafe for BoundedSender<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