pub struct AllocationBootstrap<'store> { /* private fields */ }Expand description
AllocationBootstrap
Golden-path allocation ledger bootstrap pipeline.
This type owns allocation-governance sequencing only: recover the persisted
ledger, apply the owner layer’s policy, validate current declarations
against ledger history, stage and commit the next generation, and return
ValidatedAllocations only after the commit succeeds.
AllocationBootstrap is for whichever layer owns a given ic-memory
ledger store. That owner may be a framework such as Canic, a library such as
IcyDB using ic-memory directly, or a standalone application canister. The
ownership model is not a fixed ic-memory -> Canic -> IcyDB -> application
chain.
Exactly one owner should bootstrap a given ledger store. If multiple layers
use ic-memory in the same canister, they must either compose their
declarations into one bootstrap owner or use distinct ledger stores and
allocation domains.
The owner still decides when bootstrap runs, how the ledger store is backed by stable memory, and when endpoint dispatch or stable-memory handle opening is allowed.
Implementations§
Source§impl<'store> AllocationBootstrap<'store>
impl<'store> AllocationBootstrap<'store>
Sourcepub const fn new(store: &'store mut LedgerCommitStore) -> Self
pub const fn new(store: &'store mut LedgerCommitStore) -> Self
Build a bootstrap pipeline over a protected ledger commit store.
Sourcepub fn validate_and_commit<P>(
&mut self,
snapshot: DeclarationSnapshot,
policy: &P,
committed_at: Option<u64>,
) -> Result<BootstrapCommit, BootstrapError<P::Error>>where
P: AllocationPolicy,
pub fn validate_and_commit<P>(
&mut self,
snapshot: DeclarationSnapshot,
policy: &P,
committed_at: Option<u64>,
) -> Result<BootstrapCommit, BootstrapError<P::Error>>where
P: AllocationPolicy,
Recover, validate, stage, commit, and publish one allocation generation.
Sourcepub fn initialize_validate_and_commit<P>(
&mut self,
genesis: &AllocationLedger,
snapshot: DeclarationSnapshot,
policy: &P,
committed_at: Option<u64>,
) -> Result<BootstrapCommit, BootstrapError<P::Error>>where
P: AllocationPolicy,
pub fn initialize_validate_and_commit<P>(
&mut self,
genesis: &AllocationLedger,
snapshot: DeclarationSnapshot,
policy: &P,
committed_at: Option<u64>,
) -> Result<BootstrapCommit, BootstrapError<P::Error>>where
P: AllocationPolicy,
Initialize an empty ledger store explicitly, then validate and commit.
This is the generic genesis path. The supplied genesis ledger is a
framework decision; the generic crate only guarantees that it is used
when the protected physical store is empty, never when recovery sees
corrupt or partially written state.
Sourcepub fn reserve_and_commit<P>(
&mut self,
reservations: &[AllocationDeclaration],
policy: &P,
committed_at: Option<u64>,
) -> Result<AllocationLedger, BootstrapReservationError<P::Error>>where
P: AllocationPolicy,
pub fn reserve_and_commit<P>(
&mut self,
reservations: &[AllocationDeclaration],
policy: &P,
committed_at: Option<u64>,
) -> Result<AllocationLedger, BootstrapReservationError<P::Error>>where
P: AllocationPolicy,
Recover, policy-check, reserve, and commit one reservation generation.
Sourcepub fn initialize_reserve_and_commit<P>(
&mut self,
genesis: &AllocationLedger,
reservations: &[AllocationDeclaration],
policy: &P,
committed_at: Option<u64>,
) -> Result<AllocationLedger, BootstrapReservationError<P::Error>>where
P: AllocationPolicy,
pub fn initialize_reserve_and_commit<P>(
&mut self,
genesis: &AllocationLedger,
reservations: &[AllocationDeclaration],
policy: &P,
committed_at: Option<u64>,
) -> Result<AllocationLedger, BootstrapReservationError<P::Error>>where
P: AllocationPolicy,
Initialize an empty ledger store, then reserve and commit.
Sourcepub fn retire_and_commit(
&mut self,
retirement: &AllocationRetirement,
committed_at: Option<u64>,
) -> Result<AllocationLedger, BootstrapRetirementError>
pub fn retire_and_commit( &mut self, retirement: &AllocationRetirement, committed_at: Option<u64>, ) -> Result<AllocationLedger, BootstrapRetirementError>
Recover, retire, and commit one explicit retirement generation.