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.

Object Safety§

This trait is not object safe.

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,

source§

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

source§

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

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>,

source§

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

source§

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

source§

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,

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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,

source§

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

source§

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

source§

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,

source§

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

source§

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

source§

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,

source§

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

source§

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

source§

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,

source§

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

source§

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

source§

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,

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,

source§

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

source§

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

source§

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,

source§

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

source§

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

source§

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,

source§

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

source§

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

source§

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

source§

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

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,

source§

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

source§

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

source§

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,

source§

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

source§

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

source§

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,

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,

source§

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

source§

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

source§

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,

source§

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

source§

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

source§

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,

source§

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

source§

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

source§

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,

source§

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

source§

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

source§

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

source§

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

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,

source§

impl<T> Consumer<T> for NoopConsumer

source§

impl<T, C> Consumer<T> for FlattenConsumer<C>

source§

impl<T, C> Consumer<T> for FlattenIterConsumer<C>

source§

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

source§

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