Skip to main content

step

Function step 

Source
pub fn step<P: Protocol + ?Sized>(
    p: &mut P,
    event: ProtoEvent<P>,
    now: Time,
    rng: &mut dyn RngCore,
) -> Vec<ProtoEffect<P>> ⓘ
Expand description

Deliver one event to p and return the effects it emitted.

Restores the ergonomics of a pure function for tests — assert_eq!(step(..), [..]) — without making production paths allocate a vector per event. Intended for tests; drivers own a reusable buffer and call the handlers directly.

For a protocol driven alone. This starts the timer identities at zero on every call, so a composition driven through it hands two layers the same handle and each accepts the other’s expiry as its own — a wrong test that need not fail. Use step_with for a stack, and step_in for a protocol whose writes must survive between calls. The distinction is not expressible in the type: a composed protocol looks like any other from here.