Trait rayon::iter::plumbing::Consumer

source ·
pub trait Consumer<Item>: Send + Sized {
    type Folder: Folder<Item, Result = Self::Result>;
    type Reducer: Reducer<Self::Result>;
    type Result: Send;

    // Required methods
    fn split_at(self, index: usize) -> (Self, Self, Self::Reducer);
    fn into_folder(self) -> Self::Folder;
    fn full(&self) -> bool;
}
Expand description

A consumer is effectively a generalized “fold” operation, and in fact each consumer will eventually be converted into a Folder. What makes a consumer special is that, like a Producer, it can be split into multiple consumers using the split_at method. When a consumer is split, it produces two consumers, as well as a reducer. The two consumers can be fed items independently, and when they are done the reducer is used to combine their two results into one. See the plumbing README for further details.

Required Associated Types§

source

type Folder: Folder<Item, Result = Self::Result>

The type of folder that this consumer can be converted into.

source

type Reducer: Reducer<Self::Result>

The type of reducer that is produced if this consumer is split.

source

type Result: Send

The type of result that this consumer will ultimately produce.

Required Methods§

source

fn split_at(self, index: usize) -> (Self, Self, Self::Reducer)

Divide the consumer into two consumers, one processing items 0..index and one processing items from index... Also produces a reducer that can be used to reduce the results at the end.

source

fn into_folder(self) -> Self::Folder

Convert the consumer into a folder that can consume items sequentially, eventually producing a final result.

source

fn full(&self) -> bool

Hint whether this Consumer would like to stop processing further items, e.g. if a search has been completed.

Implementors§

source§

impl Consumer<char> for ListStringConsumer

source§

impl<'a, T, C> Consumer<&'a T> for ClonedConsumer<C>where C: Consumer<T>, T: 'a + Clone,

§

type Folder = ClonedFolder<<C as Consumer<T>>::Folder>

§

type Reducer = <C as Consumer<T>>::Reducer

§

type Result = <C as Consumer<T>>::Result

source§

impl<'a, T, C> Consumer<&'a T> for CopiedConsumer<C>where C: Consumer<T>, T: 'a + Copy,

§

type Folder = CopiedFolder<<C as Consumer<T>>::Folder>

§

type Reducer = <C as Consumer<T>>::Reducer

§

type Result = <C as Consumer<T>>::Result

source§

impl<'a, T, C> Consumer<T> for PanicFuseConsumer<'a, C>where C: Consumer<T>,

§

type Folder = PanicFuseFolder<'a, <C as Consumer<T>>::Folder>

§

type Reducer = PanicFuseReducer<'a, <C as Consumer<T>>::Reducer>

§

type Result = <C as Consumer<T>>::Result

source§

impl<'a, T, OP, CA, CB> Consumer<T> for UnzipConsumer<'a, OP, CA, CB>where OP: UnzipOp<T>, CA: Consumer<OP::Left>, CB: Consumer<OP::Right>,

§

type Folder = UnzipFolder<'a, OP, <CA as Consumer<<OP as UnzipOp<T>>::Left>>::Folder, <CB as Consumer<<OP as UnzipOp<T>>::Right>>::Folder>

§

type Reducer = UnzipReducer<<CA as Consumer<<OP as UnzipOp<T>>::Left>>::Reducer, <CB as Consumer<<OP as UnzipOp<T>>::Right>>::Reducer>

§

type Result = (<CA as Consumer<<OP as UnzipOp<T>>::Left>>::Result, <CB as Consumer<<OP as UnzipOp<T>>::Right>>::Result)

source§

impl<'c, T: Send + 'c> Consumer<T> for CollectConsumer<'c, T>

source§

impl<'f, F, T> Consumer<T> for ForEachConsumer<'f, F>where F: Fn(T) + Sync,

source§

impl<'f, T, C> Consumer<Option<T>> for WhileSomeConsumer<'f, C>where C: Consumer<T>, T: Send,

§

type Folder = WhileSomeFolder<'f, <C as Consumer<T>>::Folder>

§

type Reducer = <C as Consumer<T>>::Reducer

§

type Result = <C as Consumer<T>>::Result

source§

impl<'f, T, C> Consumer<T> for SkipAnyConsumer<'f, C>where C: Consumer<T>, T: Send,

§

type Folder = SkipAnyFolder<'f, <C as Consumer<T>>::Folder>

§

type Reducer = <C as Consumer<T>>::Reducer

§

type Result = <C as Consumer<T>>::Result

source§

impl<'f, T, C> Consumer<T> for TakeAnyConsumer<'f, C>where C: Consumer<T>, T: Send,

§

type Folder = TakeAnyFolder<'f, <C as Consumer<T>>::Folder>

§

type Reducer = <C as Consumer<T>>::Reducer

§

type Result = <C as Consumer<T>>::Result

source§

impl<'f, T, C, F> Consumer<T> for InspectConsumer<'f, C, F>where C: Consumer<T>, F: Fn(&T) + Sync,

§

type Folder = InspectFolder<'f, <C as Consumer<T>>::Folder, F>

§

type Reducer = <C as Consumer<T>>::Reducer

§

type Result = <C as Consumer<T>>::Result

source§

impl<'f, T, C, F> Consumer<T> for UpdateConsumer<'f, C, F>where C: Consumer<T>, F: Fn(&mut T) + Send + Sync,

§

type Folder = UpdateFolder<'f, <C as Consumer<T>>::Folder, F>

§

type Reducer = <C as Consumer<T>>::Reducer

§

type Result = <C as Consumer<T>>::Result

source§

impl<'f, T, INIT, U, R, C, F> Consumer<T> for MapInitConsumer<'f, C, INIT, F>where C: Consumer<R>, INIT: Fn() -> U + Sync, F: Fn(&mut U, T) -> R + Sync, R: Send,

§

type Folder = MapWithFolder<'f, <C as Consumer<R>>::Folder, U, F>

§

type Reducer = <C as Consumer<R>>::Reducer

§

type Result = <C as Consumer<R>>::Result

source§

impl<'f, T, R, C, F> Consumer<T> for MapConsumer<'f, C, F>where C: Consumer<F::Output>, F: Fn(T) -> R + Sync, R: Send,

§

type Folder = MapFolder<'f, <C as Consumer<<F as FnOnce(T)>::Output>>::Folder, F>

§

type Reducer = <C as Consumer<<F as FnOnce(T)>::Output>>::Reducer

§

type Result = <C as Consumer<<F as FnOnce(T)>::Output>>::Result

source§

impl<'f, T, U, C, F> Consumer<T> for FlatMapConsumer<'f, C, F>where C: UnindexedConsumer<U::Item>, F: Fn(T) -> U + Sync, U: IntoParallelIterator,

source§

impl<'f, T, U, C, F> Consumer<T> for FlatMapIterConsumer<'f, C, F>where C: UnindexedConsumer<U::Item>, F: Fn(T) -> U + Sync, U: IntoIterator,

§

type Folder = FlatMapIterFolder<'f, <C as Consumer<<U as IntoIterator>::Item>>::Folder, F>

§

type Reducer = <C as Consumer<<U as IntoIterator>::Item>>::Reducer

§

type Result = <C as Consumer<<U as IntoIterator>::Item>>::Result

source§

impl<'f, T, U, R, C, F> Consumer<T> for MapWithConsumer<'f, C, U, F>where C: Consumer<R>, U: Send + Clone, F: Fn(&mut U, T) -> R + Sync, R: Send,

§

type Folder = MapWithFolder<'f, <C as Consumer<R>>::Folder, U, F>

§

type Reducer = <C as Consumer<R>>::Reducer

§

type Result = <C as Consumer<R>>::Result

source§

impl<'p, T, C, P> Consumer<T> for FilterConsumer<'p, C, P>where C: Consumer<T>, P: Fn(&T) -> bool + Sync + 'p,

§

type Folder = FilterFolder<'p, <C as Consumer<T>>::Folder, P>

§

type Reducer = <C as Consumer<T>>::Reducer

§

type Result = <C as Consumer<T>>::Result

source§

impl<'p, T, C, P> Consumer<T> for PositionsConsumer<'p, C, P>where C: Consumer<usize>, P: Fn(T) -> bool + Sync,

§

type Folder = PositionsFolder<'p, <C as Consumer<usize>>::Folder, P>

§

type Reducer = <C as Consumer<usize>>::Reducer

§

type Result = <C as Consumer<usize>>::Result

source§

impl<'p, T, C, P> Consumer<T> for SkipAnyWhileConsumer<'p, C, P>where C: Consumer<T>, P: Fn(&T) -> bool + Sync,

§

type Folder = SkipAnyWhileFolder<'p, <C as Consumer<T>>::Folder, P>

§

type Reducer = <C as Consumer<T>>::Reducer

§

type Result = <C as Consumer<T>>::Result

source§

impl<'p, T, C, P> Consumer<T> for TakeAnyWhileConsumer<'p, C, P>where C: Consumer<T>, P: Fn(&T) -> bool + Sync,

§

type Folder = TakeAnyWhileFolder<'p, <C as Consumer<T>>::Folder, P>

§

type Reducer = <C as Consumer<T>>::Reducer

§

type Result = <C as Consumer<T>>::Result

source§

impl<'p, T, P> Consumer<T> for rayon::iter::find::FindConsumer<'p, P>where T: Send, P: Fn(&T) -> bool + Sync + 'p,

§

type Folder = FindFolder<'p, T, P>

§

type Reducer = FindReducer

§

type Result = Option<T>

source§

impl<'p, T, P> Consumer<T> for rayon::iter::find_first_last::FindConsumer<'p, P>where T: Send, P: Fn(&T) -> bool + Sync,

§

type Folder = FindFolder<'p, T, P>

§

type Reducer = FindReducer

§

type Result = Option<T>

source§

impl<'p, T, U, C, P> Consumer<T> for FilterMapConsumer<'p, C, P>where C: Consumer<U>, P: Fn(T) -> Option<U> + Sync + 'p,

§

type Folder = FilterMapFolder<'p, <C as Consumer<U>>::Folder, P>

§

type Reducer = <C as Consumer<U>>::Reducer

§

type Result = <C as Consumer<U>>::Result

source§

impl<'r, R, ID, T> Consumer<T> for ReduceConsumer<'r, R, ID>where R: Fn(T, T) -> T + Sync, ID: Fn() -> T + Sync, T: Send,

§

type Folder = ReduceFolder<'r, R, T>

§

type Reducer = ReduceConsumer<'r, R, ID>

§

type Result = T

source§

impl<'r, R, ID, T> Consumer<T> for TryReduceConsumer<'r, R, ID>where R: Fn(T::Output, T::Output) -> T + Sync, ID: Fn() -> T::Output + Sync, T: Try + Send,

§

type Folder = TryReduceFolder<'r, R, T>

§

type Reducer = TryReduceConsumer<'r, R, ID>

§

type Result = T

source§

impl<'r, R, T> Consumer<T> for TryReduceWithConsumer<'r, R>where R: Fn(T::Output, T::Output) -> T + Sync, T: Try + Send,

source§

impl<'r, U, T, C, F> Consumer<T> for FoldWithConsumer<'r, C, U, F>where C: Consumer<U>, F: Fn(U, T) -> U + Sync, U: Send + Clone,

§

type Folder = FoldFolder<'r, <C as Consumer<U>>::Folder, U, F>

§

type Reducer = <C as Consumer<U>>::Reducer

§

type Result = <C as Consumer<U>>::Result

source§

impl<'r, U, T, C, F> Consumer<T> for TryFoldWithConsumer<'r, C, U, F>where C: Consumer<U>, F: Fn(U::Output, T) -> U + Sync, U: Try + Send, U::Output: Clone + Send,

§

type Folder = TryFoldFolder<'r, <C as Consumer<U>>::Folder, U, F>

§

type Reducer = <C as Consumer<U>>::Reducer

§

type Result = <C as Consumer<U>>::Result

source§

impl<'r, U, T, C, ID, F> Consumer<T> for FoldConsumer<'r, C, ID, F>where C: Consumer<U>, F: Fn(U, T) -> U + Sync, ID: Fn() -> U + Sync, U: Send,

§

type Folder = FoldFolder<'r, <C as Consumer<U>>::Folder, U, F>

§

type Reducer = <C as Consumer<U>>::Reducer

§

type Result = <C as Consumer<U>>::Result

source§

impl<'r, U, T, C, ID, F> Consumer<T> for TryFoldConsumer<'r, U, C, ID, F>where C: Consumer<U>, F: Fn(U::Output, T) -> U + Sync, ID: Fn() -> U::Output + Sync, U: Try + Send,

§

type Folder = TryFoldFolder<'r, <C as Consumer<U>>::Folder, U, F>

§

type Reducer = <C as Consumer<U>>::Reducer

§

type Result = <C as Consumer<U>>::Result

source§

impl<C, T> Consumer<T> for IntersperseConsumer<C, T>where C: Consumer<T>, T: Clone + Send,

§

type Folder = IntersperseFolder<<C as Consumer<T>>::Folder, T>

§

type Reducer = <C as Consumer<T>>::Reducer

§

type Result = <C as Consumer<T>>::Result

source§

impl<P, T> Consumer<T> for ProductConsumer<P>where P: Send + Product<T> + Product,

source§

impl<S, T> Consumer<T> for SumConsumer<S>where S: Send + Sum<T> + Sum,

§

type Folder = SumFolder<S>

§

type Reducer = SumConsumer<S>

§

type Result = S

source§

impl<T> Consumer<T> for NoopConsumer

source§

impl<T, C> Consumer<T> for FlattenConsumer<C>where C: UnindexedConsumer<T::Item>, T: IntoParallelIterator,

source§

impl<T, C> Consumer<T> for FlattenIterConsumer<C>where C: UnindexedConsumer<T::Item>, T: IntoIterator,

source§

impl<T: Send> Consumer<T> for ListConsumer

source§

impl<T: Send> Consumer<T> for ListVecConsumer