pub trait Processor<T> {
type Output;
type Error;
// Required methods
fn process(&self, input: T) -> impl Future<Output = Result<(), Self::Error>>;
fn next(&self) -> impl Future<Output = Result<Self::Output, Self::Error>>;
}Expand description
Interface for implementing data processors.
Processors take in items (input) and yield “processed” or “enriched” versions of them at some point (output). Please note that these items do not necessarily need to come out in the same order as they came in. Processors can keep items around until their internal logic decides they’re ready to go, and this can happen in any order required.
Users of processors will use the process method to insert “input” items and call next to
find out if there’s ready processed “output” items to take out.
The process method might apply back-pressure, for example when the processor is busy and
can’t take in more work.
Processors never terminate. The future returned by next will stay in pending state whenever
there’s no work to do or the processor can’t continue because of it’s internal logic. Users can
decide to drop a processor or escalate to a higher-level whenever an error occurs or the
processor is no longer used.
Required Associated Types§
Required Methods§
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.