Skip to main content

PageLifecycleController

Struct PageLifecycleController 

Source
pub struct PageLifecycleController { /* private fields */ }
Expand description

Unified deterministic controller managing page Freeze, Resume, Evict, Destroy, generation guards, and boundary events.

Implementations§

Source§

impl PageLifecycleController

Deterministic Freeze, Resume, Evict, Destroy, generation-guard, and boundary-event operations for PageLifecycleController.

Source

pub fn with_budget(budget: PageBudgetPolicy) -> Self

Creates a PageLifecycleController configured with explicit budget limits.

§Arguments
  • PageBudgetPolicy - Cold-page count and retained-byte retention policy.
§Returns
  • Self - Configured page lifecycle controller.
Source

pub fn register_page( &mut self, route_key: String, retention: PageRetention, parent_page_id: Option<u64>, retained_bytes: usize, reconstructible_cache_bytes: usize, ) -> PageGenerationToken

Registers a newly active page or child sub-page and returns its initial PageGenerationToken.

§Arguments
  • &Self - Mutable page lifecycle controller.
  • String - Canonical route identifier.
  • PageRetention - Retention strategy (Freeze, Destroy, Alive).
  • Option<u64> - Optional parent page_id for deterministic parent-child lifecycle propagation.
  • usize - Core retained state memory footprint in bytes.
  • usize - Reconstructible cache memory footprint in bytes (evicted before page eviction).
§Returns
  • PageGenerationToken - Generation-guarded handle for async callbacks and ownership tracking.
Source

pub fn is_token_current(&self, token: PageGenerationToken) -> bool

Returns true when token matches the current live non-evicted, non-destroyed page generation.

§Arguments
  • &Self - Page lifecycle controller reference.
  • PageGenerationToken - Candidate generation token held by an async task or timer.
§Returns
  • bool - true when writes from token are still authorized.
Source

pub fn try_commit_async_callback<F>( &mut self, token: PageGenerationToken, callback: F, ) -> bool
where F: FnOnce(),

Runs callback ONLY when token belongs to a live Active page of the exact matching generation; otherwise blocks and counts it.

§Arguments
  • &Self - Mutable page lifecycle controller.
  • PageGenerationToken - Generation token captured when the async request started.
  • F - State commit closure executed only when token is still current and active.
§Returns
  • bool - true when the callback executed; false when rejected by the generation guard.
Source

pub fn update_snapshot(&mut self, page_id: u64, snapshot: PageSnapshot) -> bool

Attaches or updates a versioned PageSnapshot (including persisted draft status) on page_id.

§Arguments
  • &Self - Mutable page lifecycle controller.
  • u64 - Target page identifier.
  • PageSnapshot - Versioned snapshot payload.
§Returns
  • bool - true if page_id exists and is not Destroyed.
Source

pub fn persist_page_draft( &mut self, page_id: u64, draft_payload: String, ) -> bool

Marks an unsaved draft on page_id durably persisted so cold eviction may proceed safely without data loss.

§Arguments
  • &Self - Mutable page lifecycle controller.
  • u64 - Target page identifier.
  • String - Persisted draft payload stored inside the page snapshot.
§Returns
  • bool - true when the draft was persisted onto the page snapshot.
Source

pub fn freeze_page( &mut self, page_id: u64, snapshot: Option<PageSnapshot>, ) -> Vec<u64>

Idempotently freezes page_id and its active descendants once without double-firing on already-frozen pages.

§Arguments
  • &Self - Mutable page lifecycle controller.
  • u64 - Target page identifier to freeze.
  • Option<PageSnapshot> - Optional fresh versioned snapshot captured before freezing.
§Returns
  • Vec<u64> - Page identifiers newly transitioned from Active to Frozen.
Source

pub fn resume_page( &mut self, page_id: u64, current_host_revision: u64, ) -> Option<(PageGenerationToken, Option<PageSnapshot>, bool)>

Idempotently resumes page_id (and frozen descendants), restoring from PageSnapshot if previously Evicted and checking host-state synchronization.

§Arguments
  • &Self - Mutable page lifecycle controller.
  • u64 - Target page identifier to resume.
  • u64 - Current authoritative host/shared-store revision.
§Returns
  • Option<(PageGenerationToken, Option<PageSnapshot>, bool)> - Active token, restored snapshot (when reconstructed or present), and host_sync_required flag.
Source

pub fn enforce_budget(&mut self) -> PageEvictionReport

Enforces bounded cold-page budgets: FIRST drains reconstructible caches, THEN evicts oldest cold Frozen pages while protecting unpersisted unsaved drafts.

§Arguments
  • &Self - Mutable page lifecycle controller.
§Returns
  • PageEvictionReport - Freed reconstructible bytes, evicted page IDs, and protected unsaved draft count.
Source

pub fn destroy_page(&mut self, page_id: u64) -> Vec<PageGenerationToken>

Explicitly destroys page_id and all descendants, bumping generation, dropping PageSnapshot, and blocking all stale async writes.

§Arguments
  • &Self - Mutable page lifecycle controller.
  • u64 - Target page identifier to destroy permanently.
§Returns
  • Vec<PageGenerationToken> - Destroyed (page_id, prior_generation) tokens for resource ownership accounting.
Source

pub fn apply_boundary_event(&mut self, event: LifecycleBoundaryEvent) -> usize

Processes a distinct OS background, surface-loss, or route-freeze boundary event without conflating their state transitions.

§Arguments
  • &Self - Mutable page lifecycle controller.
  • LifecycleBoundaryEvent - Structured boundary event.
§Returns
  • usize - Number of page entries updated by this boundary event.
Source

pub fn phase_counts(&self) -> (usize, usize, usize, u64)

Returns aggregate page counts (active, frozen, evicted, destroyed) for resource accounting snapshots.

§Arguments
  • &Self - Page lifecycle controller reference.
§Returns
  • (usize, usize, usize, u64) - Tuple (active, frozen, evicted, total_destroyed).
Source§

impl PageLifecycleController

Source

pub fn get_budget(&self) -> PageBudgetPolicy

Source

pub fn get_mut_budget(&mut self) -> &mut PageBudgetPolicy

Source

pub fn set_budget(&mut self, val: PageBudgetPolicy) -> &mut Self

Source

pub fn get_next_page_id(&self) -> u64

Source

pub fn get_active_clock(&self) -> u64

Source

pub fn get_host_revision(&self) -> u64

Source

pub fn get_mut_host_revision(&mut self) -> &mut u64

Source

pub fn set_host_revision(&mut self, val: u64) -> &mut Self

Source

pub fn get_stale_callbacks_blocked(&self) -> u64

Source

pub fn get_os_background_events(&self) -> u64

Source

pub fn get_os_foreground_events(&self) -> u64

Source

pub fn get_surface_lost_events(&self) -> u64

Source

pub fn get_surface_recreated_events(&self) -> u64

Source

pub fn get_total_destroyed_pages(&self) -> u64

Trait Implementations§

Source§

impl Clone for PageLifecycleController

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for PageLifecycleController

Source§

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

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

impl Default for PageLifecycleController

Default empty PageLifecycleController initialized with PageBudgetPolicy::default().

Source§

fn default() -> Self

Creates a new PageLifecycleController with default cold-page budgets.

§Returns
  • Self - Initialized page lifecycle controller.

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
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<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 = !

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

fn try_from(value: U) -> Result<T, !>

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.