Skip to main content

AllocationBootstrap

Struct AllocationBootstrap 

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

Source

pub const fn new(store: &'store mut LedgerCommitStore) -> Self

Build a bootstrap pipeline over a protected ledger commit store.

Source

pub fn validate_and_commit<C, P>( &mut self, codec: &C, snapshot: DeclarationSnapshot, policy: &P, committed_at: Option<u64>, ) -> Result<BootstrapCommit, BootstrapError<C::Error, P::Error>>

Recover, validate, stage, commit, and publish one allocation generation.

Source

pub fn initialize_validate_and_commit<C, P>( &mut self, codec: &C, genesis: &AllocationLedger, snapshot: DeclarationSnapshot, policy: &P, committed_at: Option<u64>, ) -> Result<BootstrapCommit, BootstrapError<C::Error, P::Error>>

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.

Source

pub fn reserve_and_commit<C, P>( &mut self, codec: &C, reservations: &[AllocationDeclaration], policy: &P, committed_at: Option<u64>, ) -> Result<AllocationLedger, BootstrapReservationError<C::Error, P::Error>>

Recover, policy-check, reserve, and commit one reservation generation.

Source

pub fn initialize_reserve_and_commit<C, P>( &mut self, codec: &C, genesis: &AllocationLedger, reservations: &[AllocationDeclaration], policy: &P, committed_at: Option<u64>, ) -> Result<AllocationLedger, BootstrapReservationError<C::Error, P::Error>>

Initialize an empty ledger store, then reserve and commit.

Source

pub fn retire_and_commit<C>( &mut self, codec: &C, retirement: &AllocationRetirement, committed_at: Option<u64>, ) -> Result<AllocationLedger, BootstrapRetirementError<C::Error>>
where C: LedgerCodec,

Recover, retire, and commit one explicit retirement generation.

Trait Implementations§

Source§

impl<'store> Debug for AllocationBootstrap<'store>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'store> Freeze for AllocationBootstrap<'store>

§

impl<'store> RefUnwindSafe for AllocationBootstrap<'store>

§

impl<'store> Send for AllocationBootstrap<'store>

§

impl<'store> Sync for AllocationBootstrap<'store>

§

impl<'store> Unpin for AllocationBootstrap<'store>

§

impl<'store> UnsafeUnpin for AllocationBootstrap<'store>

§

impl<'store> !UnwindSafe for AllocationBootstrap<'store>

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