pub trait ConcurrentStream {
type Item;
type Future: Future<Output = Self::Item>;
// Required methods
async fn drive<C>(self, consumer: C) -> C::Output
where C: Consumer<Self::Item, Self::Future>;
fn concurrency_limit(&self) -> Option<NonZeroUsize>;
// Provided methods
fn size_hint(&self) -> (usize, Option<usize>) { ... }
fn enumerate(self) -> Enumerate<Self>
where Self: Sized { ... }
fn limit(self, limit: Option<NonZeroUsize>) -> Limit<Self>
where Self: Sized { ... }
fn take(self, limit: usize) -> Take<Self>
where Self: Sized { ... }
fn map<F, FutB, B>(
self,
f: F,
) -> Map<Self, F, Self::Future, Self::Item, FutB, B>
where Self: Sized,
F: Fn(Self::Item) -> FutB + Clone,
FutB: Future<Output = B> { ... }
async fn for_each<F, Fut>(self, f: F)
where Self: Sized,
F: Fn(Self::Item) -> Fut + Clone,
Fut: Future<Output = ()> { ... }
async fn try_for_each<F, Fut, E>(self, f: F) -> Result<(), E>
where Self: Sized,
F: Fn(Self::Item) -> Fut + Clone,
Fut: Future<Output = Result<(), E>> { ... }
async fn collect<B>(self) -> B
where B: FromConcurrentStream<Self::Item>,
Self: Sized { ... }
}
Expand description
Concurrently operate over items in a stream
Required Associated Types§
Required Methods§
sourceasync fn drive<C>(self, consumer: C) -> C::Output
async fn drive<C>(self, consumer: C) -> C::Output
Internal method used to define the behavior of this concurrent iterator. You should not need to call this directly. This method causes the iterator self to start producing items and to feed them to the consumer consumer one by one.
sourcefn concurrency_limit(&self) -> Option<NonZeroUsize>
fn concurrency_limit(&self) -> Option<NonZeroUsize>
How much concurrency should we apply?
Provided Methods§
sourcefn size_hint(&self) -> (usize, Option<usize>)
fn size_hint(&self) -> (usize, Option<usize>)
How many items could we potentially end up returning?
sourcefn enumerate(self) -> Enumerate<Self>where
Self: Sized,
fn enumerate(self) -> Enumerate<Self>where
Self: Sized,
Creates a stream which gives the current iteration count as well as the next value.
The value is determined by the moment the future is created, not the moment the future is evaluated.
sourcefn limit(self, limit: Option<NonZeroUsize>) -> Limit<Self>where
Self: Sized,
fn limit(self, limit: Option<NonZeroUsize>) -> Limit<Self>where
Self: Sized,
Obtain a simple pass-through adapter.
sourcefn take(self, limit: usize) -> Take<Self>where
Self: Sized,
fn take(self, limit: usize) -> Take<Self>where
Self: Sized,
Creates a stream that yields the first n
elements, or fewer if the
underlying iterator ends sooner.
sourcefn map<F, FutB, B>(
self,
f: F,
) -> Map<Self, F, Self::Future, Self::Item, FutB, B>
fn map<F, FutB, B>( self, f: F, ) -> Map<Self, F, Self::Future, Self::Item, FutB, B>
Convert items from one type into another
sourceasync fn try_for_each<F, Fut, E>(self, f: F) -> Result<(), E>
async fn try_for_each<F, Fut, E>(self, f: F) -> Result<(), E>
Iterate over each item concurrently, short-circuit on error.
If an error is returned this will cancel all other futures.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.