pub struct PresentationLifecycle { /* private fields */ }Expand description
Pure retained lifecycle model for one logical window.
The logical ID survives suspension and attachment generations. The type owns no native resource and can be cloned for deterministic state inspection.
§Examples
use ailloli_ui_runtime::app::{PresentationGeneration, PresentationLifecycle, PresentationState};
let lifecycle = PresentationLifecycle::new("main");
assert_eq!(lifecycle.logical_window_id().as_str(), "main");
assert_eq!(lifecycle.state(), PresentationState::Declared);
assert_eq!(lifecycle.generation(), PresentationGeneration::INITIAL);Implementations§
Source§impl PresentationLifecycle
Provides the operations defined for PresentationLifecycle.
impl PresentationLifecycle
Provides the operations defined for PresentationLifecycle.
Sourcepub fn new(logical_window_id: impl Into<LogicalWindowId>) -> Self
pub fn new(logical_window_id: impl Into<LogicalWindowId>) -> Self
Creates a declared logical window at generation zero.
The ID is stored exactly by [LogicalWindowId]; empty IDs are
representable at this layer and host declaration logic owns uniqueness.
§Examples
use ailloli_ui_runtime::app::{PresentationGeneration, PresentationLifecycle, PresentationState};
let lifecycle = PresentationLifecycle::new(String::from("settings"));
assert_eq!(lifecycle.state(), PresentationState::Declared);
assert_eq!(lifecycle.generation(), PresentationGeneration::INITIAL);Sourcepub fn logical_window_id(&self) -> &LogicalWindowId
pub fn logical_window_id(&self) -> &LogicalWindowId
Borrows the stable logical-window identifier.
§Examples
use ailloli_ui_runtime::app::PresentationLifecycle;
let lifecycle = PresentationLifecycle::new("main");
assert_eq!(lifecycle.logical_window_id().as_str(), "main");Sourcepub const fn state(&self) -> PresentationState
pub const fn state(&self) -> PresentationState
Returns the current lifecycle state.
§Examples
use ailloli_ui_runtime::app::{PresentationLifecycle, PresentationState};
assert_eq!(PresentationLifecycle::new("main").state(), PresentationState::Declared);Sourcepub const fn generation(&self) -> PresentationGeneration
pub const fn generation(&self) -> PresentationGeneration
Returns the current native-attachment generation.
§Examples
use ailloli_ui_runtime::app::{PresentationGeneration, PresentationLifecycle};
assert_eq!(PresentationLifecycle::new("main").generation(), PresentationGeneration::INITIAL);Sourcepub fn accepts(&self, generation: PresentationGeneration) -> bool
pub fn accepts(&self, generation: PresentationGeneration) -> bool
Returns whether events from generation belong to the ready presentation.
Matching generations are rejected unless state is exactly
PresentationState::Ready, preventing stale events during suspension,
recreation, or destruction.
§Examples
use ailloli_ui_runtime::app::{PresentationEvent, PresentationGeneration, PresentationLifecycle};
let mut lifecycle = PresentationLifecycle::new("main");
assert!(!lifecycle.accepts(PresentationGeneration::INITIAL));
lifecycle.apply(PresentationEvent::AllowCreation)?;
lifecycle.apply(PresentationEvent::Attached)?;
assert!(lifecycle.accepts(PresentationGeneration::new(1)));Sourcepub fn apply(
&mut self,
event: PresentationEvent,
) -> Result<PresentationReduction, PresentationTransitionError>
pub fn apply( &mut self, event: PresentationEvent, ) -> Result<PresentationReduction, PresentationTransitionError>
Applies one pure reducer event and commits it only on success.
§Errors
Returns the same errors as reduce_presentation. State and generation
remain unchanged when reduction fails.
§Examples
use ailloli_ui_runtime::app::{PresentationEvent, PresentationGeneration, PresentationLifecycle, PresentationState};
let mut lifecycle = PresentationLifecycle::new("main");
lifecycle.apply(PresentationEvent::AllowCreation)?;
let attached = lifecycle.apply(PresentationEvent::Attached)?;
assert_eq!(lifecycle.state(), PresentationState::Ready);
assert_eq!(attached.generation, PresentationGeneration::new(1));Trait Implementations§
Source§impl Clone for PresentationLifecycle
impl Clone for PresentationLifecycle
Source§fn clone(&self) -> PresentationLifecycle
fn clone(&self) -> PresentationLifecycle
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PresentationLifecycle
impl Debug for PresentationLifecycle
Source§impl PartialEq for PresentationLifecycle
impl PartialEq for PresentationLifecycle
impl Eq for PresentationLifecycle
impl StructuralPartialEq for PresentationLifecycle
Auto Trait Implementations§
impl Freeze for PresentationLifecycle
impl RefUnwindSafe for PresentationLifecycle
impl Send for PresentationLifecycle
impl Sync for PresentationLifecycle
impl Unpin for PresentationLifecycle
impl UnwindSafe for PresentationLifecycle
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<A> IntoClickAction<A> for Awhere
A: Clone + 'static,
impl<A> IntoClickAction<A> for Awhere
A: Clone + 'static,
Source§fn into_click_action(self) -> ClickAction<A>
fn into_click_action(self) -> ClickAction<A>
Implements the into_click_action helper used by this module.