pub trait Processor {
type Effect;
// Provided methods
fn decide_data(&mut self, _frame: &DataFrame) -> Decision<Self::Effect> { ... }
fn decide_system(
&mut self,
_dir: Direction,
_frame: &SystemFrame,
) -> Decision<Self::Effect> { ... }
}Expand description
The pure core of a stage.
Both methods are synchronous and total — no .await, no I/O — so they
cannot be cancelled mid-step. All state mutation happens here; perform
(in the runtime) is &self so a dropped future can’t tear state.
Effect is the stage’s own command vocabulary: plain data defined in core.
The methods emit commands describing what should happen; the runtime’s
perform interprets them and does the I/O.
§Control calls
“No I/O” has one carve-out. decide_* may issue control calls:
synchronous, non-blocking, idempotent, infallible operations on owned
engines. The canonical example is cancel(), which flips an atomic flag an
engine’s worker observes; it cannot block, fail, allocate unboundedly, or
tear state, so invoking it from the synchronous, &mut self decide step is
sound. Anything that can block, fail, allocate unboundedly, or perform real
I/O is not a control call — it remains an Effect
for perform to carry out.
§Defaults
Both methods default to Decision::forward(): an un-overridden stage is a
transparent pass-through. Override only the variants you care about.
Required Associated Types§
Provided Methods§
Sourcefn decide_data(&mut self, _frame: &DataFrame) -> Decision<Self::Effect>
fn decide_data(&mut self, _frame: &DataFrame) -> Decision<Self::Effect>
Maps an incoming data frame to a disposition and zero or more effects.
Called for every DataFrame arriving on the data lane. The default
forwards the frame unchanged.
Sourcefn decide_system(
&mut self,
_dir: Direction,
_frame: &SystemFrame,
) -> Decision<Self::Effect>
fn decide_system( &mut self, _dir: Direction, _frame: &SystemFrame, ) -> Decision<Self::Effect>
Maps an incoming system frame to a disposition and zero or more effects.
Called for every SystemFrame arriving on the system lane, along with
the Direction it is travelling. The default forwards the frame.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".