Skip to main content

Reducer

Trait Reducer 

Source
pub trait Reducer {
    type Input;

    // Required methods
    fn step(&mut self, input: Self::Input) -> Vec<Event>;
    fn poll(&mut self) -> Vec<Event>;
    fn command(&mut self, c: Command) -> Vec<Event>;

    // Provided methods
    fn prelude(&mut self, _input: &Self::Input) -> Vec<Event> { ... }
    fn finish(&mut self) -> Vec<Event> { ... }
}
Expand description

The reducer driven by the pipeline.

The session state of the session module implements this trait. If the session has the immutable-value form (step(&Session, FrameSet) -> (Session, Vec<Event>)), implement it as a thin adapter that holds the current session and replaces it with the new session in step.

Required Associated Types§

Source

type Input

Input pushed in one go (e.g. the frame bundle of one position).

Required Methods§

Source

fn step(&mut self, input: Self::Input) -> Vec<Event>

Process one input and return the resulting events in order.

Source

fn poll(&mut self) -> Vec<Event>

Collect finished background work (refinement etc.). Does not wait.

Source

fn command(&mut self, c: Command) -> Vec<Event>

Process a command.

Provided Methods§

Source

fn prelude(&mut self, _input: &Self::Input) -> Vec<Event>

Events to emit as soon as the input is received, before step processes it (e.g. decoded frames). Default: none.

Source

fn finish(&mut self) -> Vec<Event>

Wait until all remaining background work finishes and collect it. The default implementation is a single poll. Reducers with background work must override it.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl Reducer for Session

The session as a reducer driven by crate::pipeline::Pipeline. finish closes the remaining zones and waits for all background refinement jobs.