Struct PresentationLifecycle

Source
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.

Source

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);
Source

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");
Source

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);
Source

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);
Source

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)));
Source

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

Source§

fn clone(&self) -> PresentationLifecycle

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PresentationLifecycle

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for PresentationLifecycle

Source§

fn eq(&self, other: &PresentationLifecycle) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for PresentationLifecycle

Source§

impl StructuralPartialEq for PresentationLifecycle

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<A> IntoClickAction<A> for A
where A: Clone + 'static,

Source§

fn into_click_action(self) -> ClickAction<A>

Implements the into_click_action helper used by this module.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> Props for T
where T: Clone + 'static,