Skip to main content

AsyncIterator

Trait AsyncIterator 

Source
pub trait AsyncIterator: Send {
    type Item: Send;

    // Required method
    fn into_vec(self) -> Vec<Self::Item>
       where Self: Sized;

    // Provided methods
    fn map<F, Fut, R>(self, map_fn: F) -> AsyncMap<Self, F>
       where Self: Sized,
             F: Fn(Self::Item) -> Fut + Send + Sync,
             Fut: Future<Output = R> + Send,
             R: Send { ... }
    fn filter<F, Fut>(self, filter_fn: F) -> AsyncFilter<Self, F>
       where Self: Sized,
             F: Fn(&Self::Item) -> Fut + Send + Sync,
             Fut: Future<Output = bool> + Send { ... }
    fn take(self, count: usize) -> AsyncTake<Self>
       where Self: Sized { ... }
    fn skip(self, count: usize) -> AsyncSkip<Self>
       where Self: Sized { ... }
    fn enumerate(self) -> AsyncEnumerate<Self>
       where Self: Sized { ... }
    fn zip<J>(self, other: J) -> AsyncZip<Self, J>
       where Self: Sized,
             J: AsyncIterator { ... }
    fn for_each<F, Fut>(self, func: F) -> AsyncForEach<Self, F> ⓘ
       where Self: Sized,
             F: Fn(Self::Item) -> Fut + Send + Sync,
             Fut: Future<Output = ()> + Send { ... }
    fn collect<C>(self) -> AsyncCollect<Self, C> ⓘ
       where Self: Sized,
             C: Default + Extend<Self::Item> + Send { ... }
    fn fold<T, F, Fut>(self, init: T, fold_fn: F) -> AsyncFold<Self, T, F> ⓘ
       where Self: Sized,
             F: Fn(T, Self::Item) -> Fut + Send + Sync,
             Fut: Future<Output = T> + Send,
             T: Send { ... }
    fn reduce<F, Fut>(self, reduce_fn: F) -> AsyncReduce<Self, F> ⓘ
       where Self: Sized,
             F: Fn(Self::Item, Self::Item) -> Fut + Send + Sync,
             Fut: Future<Output = Self::Item> + Send { ... }
    fn into_parallel(self) -> AsyncParallelAdapter<Self>
       where Self: Sized { ... }
}
Expand description

Core async iterator trait for async/await compatible iteration

Required Associated Types§

Source

type Item: Send

The type of items yielded by this async iterator

Required Methods§

Source

fn into_vec(self) -> Vec<Self::Item>
where Self: Sized,

Materialize the iterator into its logical item sequence.

Provided Methods§

Source

fn map<F, Fut, R>(self, map_fn: F) -> AsyncMap<Self, F>
where Self: Sized, F: Fn(Self::Item) -> Fut + Send + Sync, Fut: Future<Output = R> + Send, R: Send,

Async map operation that transforms each element

Source

fn filter<F, Fut>(self, filter_fn: F) -> AsyncFilter<Self, F>
where Self: Sized, F: Fn(&Self::Item) -> Fut + Send + Sync, Fut: Future<Output = bool> + Send,

Async filter operation

Source

fn take(self, count: usize) -> AsyncTake<Self>
where Self: Sized,

Retain at most count items from the logical async stream prefix.

Source

fn skip(self, count: usize) -> AsyncSkip<Self>
where Self: Sized,

Discard count items from the logical async stream prefix.

Source

fn enumerate(self) -> AsyncEnumerate<Self>
where Self: Sized,

Pair each item with its zero-based logical stream position.

Source

fn zip<J>(self, other: J) -> AsyncZip<Self, J>
where Self: Sized, J: AsyncIterator,

Pair items with another async iterator, stopping at the shorter input.

Source

fn for_each<F, Fut>(self, func: F) -> AsyncForEach<Self, F> ⓘ
where Self: Sized, F: Fn(Self::Item) -> Fut + Send + Sync, Fut: Future<Output = ()> + Send,

Async for_each operation with side effects

Source

fn collect<C>(self) -> AsyncCollect<Self, C> ⓘ
where Self: Sized, C: Default + Extend<Self::Item> + Send,

Collect into a vector asynchronously

Source

fn fold<T, F, Fut>(self, init: T, fold_fn: F) -> AsyncFold<Self, T, F> ⓘ
where Self: Sized, F: Fn(T, Self::Item) -> Fut + Send + Sync, Fut: Future<Output = T> + Send, T: Send,

Fold operation with async function

Source

fn reduce<F, Fut>(self, reduce_fn: F) -> AsyncReduce<Self, F> ⓘ
where Self: Sized, F: Fn(Self::Item, Self::Item) -> Fut + Send + Sync, Fut: Future<Output = Self::Item> + Send,

Reduce operation for async iterators

Source

fn into_parallel(self) -> AsyncParallelAdapter<Self>
where Self: Sized,

Convert to parallel iterator for hybrid processing

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl AsyncIterator for AsyncRangeIter

Source§

impl<I, F, Fut, R> AsyncIterator for AsyncMap<I, F>
where I: AsyncIterator, F: Fn(<I as AsyncIterator>::Item) -> Fut + Send + Sync, Fut: Future<Output = R> + Send, R: Send,

Source§

type Item = R

Source§

impl<I, F, Fut, R> AsyncIterator for ParAsyncMap<I, F>
where I: AsyncIterator, F: Fn(<I as AsyncIterator>::Item) -> Fut + Send + Sync, Fut: Future<Output = R> + Send, R: Send,

Source§

type Item = R

Source§

impl<I, F, Fut> AsyncIterator for AsyncFilter<I, F>
where I: AsyncIterator, F: Fn(&<I as AsyncIterator>::Item) -> Fut + Send + Sync, Fut: Future<Output = bool> + Send,

Source§

impl<I, F, Fut> AsyncIterator for ParAsyncFilter<I, F>
where I: AsyncIterator, F: Fn(&<I as AsyncIterator>::Item) -> Fut + Send + Sync, Fut: Future<Output = bool> + Send,

Source§

impl<I, J> AsyncIterator for AsyncZip<I, J>

Source§

impl<I> AsyncIterator for AsyncEnumerate<I>
where I: AsyncIterator,

Source§

impl<I> AsyncIterator for AsyncParallelAdapter<I>
where I: AsyncIterator,

Source§

impl<I> AsyncIterator for AsyncSkip<I>
where I: AsyncIterator,

Source§

impl<I> AsyncIterator for AsyncTake<I>
where I: AsyncIterator,

Source§

impl<T> AsyncIterator for AsyncVecIter<T>
where T: Send + 'static,

Source§

type Item = T