pub struct AsyncMap<I, F> { /* private fields */ }Expand description
An asynchronous iterator adapter that maps each item to a new value using an async function.
AsyncMap is similar to the standard .map() method on iterators, but it supports asynchronous closures
by allowing the mapping function to return a Future. This makes it useful for scenarios where each item
in an iterator needs to be processed using asynchronous logic.
This struct is created by the .map_async() method on AsyncIterTools.
§Type Parameters
I: The underlying async iterator.F: The asynchronous mapping function, which produces a future for each item.
Trait Implementations§
Source§impl<B, I, F, Fut> AsyncIterator for AsyncMap<I, F>
Implements the AsyncIterator trait for AsyncMap, yielding the result of applying
the async mapping function f to each item from the underlying iterator iter.
impl<B, I, F, Fut> AsyncIterator for AsyncMap<I, F>
Implements the AsyncIterator trait for AsyncMap, yielding the result of applying
the async mapping function f to each item from the underlying iterator iter.
The next_async() method awaits the next item and then applies the mapping function,
awaiting its result before yielding it downstream.
Source§async fn next_async(&mut self) -> Option<Self::Item>
async fn next_async(&mut self) -> Option<Self::Item>
Source§fn async_size_hint(&self) -> (usize, Option<usize>)
fn async_size_hint(&self) -> (usize, Option<usize>)
Source§fn sync_iter(&mut self) -> impl Future<Output = SyncIter<IntoIter<Self::Item>>>where
Self: Sized,
fn sync_iter(&mut self) -> impl Future<Output = SyncIter<IntoIter<Self::Item>>>where
Self: Sized,
Source§fn async_collect<B>(self) -> impl Future<Output = B>
fn async_collect<B>(self) -> impl Future<Output = B>
Source§impl<I, F> Debug for AsyncMap<I, F>where
I: AsyncIterator + Debug,
Provides a Debug implementation for AsyncMap that includes debug output for the underlying iterator.
The mapping function f is not shown due to lack of generic support for Debug on closures.
impl<I, F> Debug for AsyncMap<I, F>where
I: AsyncIterator + Debug,
Provides a Debug implementation for AsyncMap that includes debug output for the underlying iterator.
The mapping function f is not shown due to lack of generic support for Debug on closures.
Source§impl<B, I, F, Fut> Future for AsyncMap<I, F>
Allows an AsyncMap to be .awaited directly, returning a synchronous iterator (SyncIter) over
the collected results of the async mapping operation. This makes it possible to use .await on
AsyncMap to collect all results at once in blocking contexts like block_on.
impl<B, I, F, Fut> Future for AsyncMap<I, F>
Allows an AsyncMap to be .awaited directly, returning a synchronous iterator (SyncIter) over
the collected results of the async mapping operation. This makes it possible to use .await on
AsyncMap to collect all results at once in blocking contexts like block_on.
Source§impl<B, I, F, Fut> PollSyncIter for AsyncMap<I, F>
Enables conversion of an AsyncMap into a synchronous SyncIter by polling the async iterator
and collecting items into a vector. Implements the PollSyncIter trait, allowing integration with
the Future implementation below.
impl<B, I, F, Fut> PollSyncIter for AsyncMap<I, F>
Enables conversion of an AsyncMap into a synchronous SyncIter by polling the async iterator
and collecting items into a vector. Implements the PollSyncIter trait, allowing integration with
the Future implementation below.
Auto Trait Implementations§
impl<I, F> Freeze for AsyncMap<I, F>
impl<I, F> RefUnwindSafe for AsyncMap<I, F>where
I: RefUnwindSafe,
F: RefUnwindSafe,
impl<I, F> Send for AsyncMap<I, F>
impl<I, F> Sync for AsyncMap<I, F>
impl<I, F> Unpin for AsyncMap<I, F>
impl<I, F> UnsafeUnpin for AsyncMap<I, F>where
I: UnsafeUnpin,
F: UnsafeUnpin,
impl<I, F> UnwindSafe for AsyncMap<I, F>where
I: UnwindSafe,
F: UnwindSafe,
Blanket Implementations§
Source§impl<T> AsyncIterTools for Twhere
T: AsyncIterator + ?Sized,
impl<T> AsyncIterTools for Twhere
T: AsyncIterator + ?Sized,
Source§fn for_each_async<F, Fut>(self, f: F) -> impl Future<Output = ()>
fn for_each_async<F, Fut>(self, f: F) -> impl Future<Output = ()>
Source§fn map_async<B, F, Fut>(self, f: F) -> AsyncMap<Self, F> ⓘ
fn map_async<B, F, Fut>(self, f: F) -> AsyncMap<Self, F> ⓘ
Source§fn filter_async<F, Fut>(self, f: F) -> AsyncFilter<Self, F> ⓘ
fn filter_async<F, Fut>(self, f: F) -> AsyncFilter<Self, F> ⓘ
Source§fn process_results<T, E>(self) -> ProcessResults<Self, T, E> ⓘ
fn process_results<T, E>(self) -> ProcessResults<Self, T, E> ⓘ
ProcessResults future that collects
successes and errors based on a specified strategy. Read more