pub trait Consumer<I>:
WithSetup
+ Send
+ Sized {
type Folder: Folder<I, Result = Self::Result>;
type Reducer: Reducer<Self::Result>;
type Result: Send;
// Required method
fn into_folder(self) -> Self::Folder;
// Provided methods
fn split(self) -> (Self, Self, Self::Reducer) { ... }
fn split_at(self, _index: usize) -> (Self, Self, Self::Reducer) { ... }
fn is_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_off_left 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 README for further
details.
Required Associated Types§
Sourcetype Folder: Folder<I, Result = Self::Result>
type Folder: Folder<I, Result = Self::Result>
The type of folder that this consumer can be converted into.
Required Methods§
Sourcefn into_folder(self) -> Self::Folder
fn into_folder(self) -> Self::Folder
Convert the consumer into a folder that can consume items sequentially, eventually producing a final result.
Provided Methods§
Sourcefn split(self) -> (Self, Self, Self::Reducer)
fn split(self) -> (Self, Self, Self::Reducer)
Divide the consumer into two consumers, one processing the left items and one processing the right items from. Also produces a reducer that can be used to reduce the results at the end.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.