pub trait GeneratorStep<CONTEXT, STATE, ITEM> {
// Required method
fn step(context: &CONTEXT, state: &mut STATE) -> Completable<Option<ITEM>>;
}Expand description
Defines a single step of a Generator.
Implement this trait to define the logic for generating items.
Each call to step should either:
- Return
Ok(Some(item))to yield an item - Return
Ok(None)when the generator is exhausted - Return
Err(Incomplete::Suspended)to yield control without producing an item - Return
Err(Incomplete::Cancelled(_))if cancellation was detected
§Type Parameters
CONTEXT: Immutable configuration/input for the generatorSTATE: Mutable state that persists across stepsITEM: The type of items produced by the generator
Required Methods§
Sourcefn step(context: &CONTEXT, state: &mut STATE) -> Completable<Option<ITEM>>
fn step(context: &CONTEXT, state: &mut STATE) -> Completable<Option<ITEM>>
Execute one step of the generator.
Returns Some(item) to yield an item, or None when exhausted.
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.