pub fn reduce_presentation(
state: PresentationState,
generation: PresentationGeneration,
event: PresentationEvent,
) -> Result<PresentationReduction, PresentationTransitionError>Expand description
Reduces one lifecycle event without accessing a native host or GPU.
Attached is valid only from PresentationState::CreationAllowed and
checked-increments generation. Retry is valid only from Unavailable.
AllowCreation is idempotent for already-allowed/ready states and re-enables
suspended or unavailable states. Suspend, Unavailable, and Destroy otherwise
replace any non-destroyed state. Destroy is idempotent once destroyed; every
other event then returns PresentationTransitionError::Destroyed.
§Errors
Returns a transition error for disallowed attach/retry, generation overflow, or any non-Destroy event after destruction.
§Examples
use ailloli_ui_runtime::app::{reduce_presentation, PresentationEvent, PresentationGeneration, PresentationState};
let allowed = reduce_presentation(PresentationState::Declared, PresentationGeneration::INITIAL, PresentationEvent::AllowCreation)?;
let ready = reduce_presentation(allowed.state, allowed.generation, PresentationEvent::Attached)?;
assert_eq!(ready.state, PresentationState::Ready);
assert_eq!(ready.generation.get(), 1);
assert!(ready.generation_changed);