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.
impl PageLifecycleController
Deterministic Freeze, Resume, Evict, Destroy, generation-guard, and boundary-event operations for PageLifecycleController.
Sourcepub fn with_budget(budget: PageBudgetPolicy) -> Self
pub fn with_budget(budget: PageBudgetPolicy) -> Self
Sourcepub fn register_page(
&mut self,
route_key: String,
retention: PageRetention,
parent_page_id: Option<u64>,
retained_bytes: usize,
reconstructible_cache_bytes: usize,
) -> PageGenerationToken
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 parentpage_idfor 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.
Sourcepub fn is_token_current(&self, token: PageGenerationToken) -> bool
pub fn is_token_current(&self, token: PageGenerationToken) -> bool
Sourcepub fn try_commit_async_callback<F>(
&mut self,
token: PageGenerationToken,
callback: F,
) -> boolwhere
F: FnOnce(),
pub fn try_commit_async_callback<F>(
&mut self,
token: PageGenerationToken,
callback: F,
) -> boolwhere
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 whentokenis still current and active.
§Returns
bool-truewhen the callback executed;falsewhen rejected by the generation guard.
Sourcepub fn update_snapshot(&mut self, page_id: u64, snapshot: PageSnapshot) -> bool
pub fn update_snapshot(&mut self, page_id: u64, snapshot: PageSnapshot) -> bool
Sourcepub fn persist_page_draft(
&mut self,
page_id: u64,
draft_payload: String,
) -> bool
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-truewhen the draft was persisted onto the page snapshot.
Sourcepub fn freeze_page(
&mut self,
page_id: u64,
snapshot: Option<PageSnapshot>,
) -> Vec<u64>
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 fromActivetoFrozen.
Sourcepub fn resume_page(
&mut self,
page_id: u64,
current_host_revision: u64,
) -> Option<(PageGenerationToken, Option<PageSnapshot>, bool)>
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), andhost_sync_requiredflag.
Sourcepub fn enforce_budget(&mut self) -> PageEvictionReport
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.
Sourcepub fn destroy_page(&mut self, page_id: u64) -> Vec<PageGenerationToken>
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.
Sourcepub fn apply_boundary_event(&mut self, event: LifecycleBoundaryEvent) -> usize
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.