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 method
    fn finish(&mut self) -> Vec<Event> { ... }
}
Expand description

파이프라인이 구동하는 리듀서.

session 모듈의 세션 상태가 이 trait 를 구현한다. 세션이 불변 값 (step(&Session, FrameSet) -> (Session, Vec<Event>)) 형태라면 내부에 현재 세션을 들고 step 에서 새 세션으로 교체하는 얇은 어댑터로 구현하면 된다.

Required Associated Types§

Source

type Input

한 번에 밀어 넣는 입력(예: 위치 하나의 프레임 묶음).

Required Methods§

Source

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

입력 하나를 처리하고 그 결과 이벤트를 순서대로 돌려준다.

Source

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

백그라운드 작업(정밀 처리 등) 중 끝난 것을 수거한다. 기다리지 않는다.

Source

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

명령을 처리한다.

Provided Methods§

Source

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

남은 백그라운드 작업을 모두 끝날 때까지 기다려 수거한다. 기본 구현은 poll 한 번. 백그라운드 작업이 있는 리듀서는 재정의해야 한다.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl Reducer for Session

crate::pipeline::Pipeline 이 구동하는 리듀서로서의 세션. finish 는 남은 구역을 닫고 배경 정밀 작업을 모두 기다린다.