pub struct TryFlatMap<Page, Err>(/* private fields */);
Expand description
Utility wrapper to flatten paginated results
When flattening paginated results, it’s most convenient to produce an iterator where the Result
is present in each item. This provides items()
which can wrap an stream of Result<Page, Err>
and produce a stream of Result<Item, Err>
.
Implementations§
Source§impl<Page, Err> TryFlatMap<Page, Err>
impl<Page, Err> TryFlatMap<Page, Err>
Sourcepub fn new(stream: PaginationStream<Result<Page, Err>>) -> Self
pub fn new(stream: PaginationStream<Result<Page, Err>>) -> Self
Creates a TryFlatMap
that wraps the input.
Sourcepub fn flat_map<M, Item, Iter>(
self,
map: M,
) -> PaginationStream<Result<Item, Err>>where
Page: Send + 'static,
Err: Send + 'static,
M: Fn(Page) -> Iter + Send + 'static,
Item: Send + 'static,
Iter: IntoIterator<Item = Item> + Send,
<Iter as IntoIterator>::IntoIter: Send,
pub fn flat_map<M, Item, Iter>(
self,
map: M,
) -> PaginationStream<Result<Item, Err>>where
Page: Send + 'static,
Err: Send + 'static,
M: Fn(Page) -> Iter + Send + 'static,
Item: Send + 'static,
Iter: IntoIterator<Item = Item> + Send,
<Iter as IntoIterator>::IntoIter: Send,
Produces a new PaginationStream
by mapping this stream with map
then flattening the result.
Trait Implementations§
Auto Trait Implementations§
impl<Page, Err> Freeze for TryFlatMap<Page, Err>
impl<Page, Err> !RefUnwindSafe for TryFlatMap<Page, Err>
impl<Page, Err> Send for TryFlatMap<Page, Err>
impl<Page, Err> !Sync for TryFlatMap<Page, Err>
impl<Page, Err> Unpin for TryFlatMap<Page, Err>
impl<Page, Err> !UnwindSafe for TryFlatMap<Page, Err>
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