pub struct AllocationLedger { /* private fields */ }Expand description
AllocationLedger
Durable root of allocation history.
Decoded ledgers are input from persistent storage and should be treated as
untrusted until compatibility and integrity validation pass. Public
construction goes through AllocationLedger::new, which validates
structural history invariants before returning a value. Use
AllocationLedger::new_committed when the value should also satisfy the
strict committed-generation chain required by recovery and commit.
Implementations§
Source§impl AllocationLedger
impl AllocationLedger
Sourcepub fn validate_integrity(&self) -> Result<(), LedgerIntegrityError>
pub fn validate_integrity(&self) -> Result<(), LedgerIntegrityError>
Validate structural ledger invariants before recovery or commit.
Sourcepub fn validate_committed_integrity(&self) -> Result<(), LedgerIntegrityError>
pub fn validate_committed_integrity(&self) -> Result<(), LedgerIntegrityError>
Validate strict committed-ledger invariants before recovery or commit.
Public durable structs are DTOs: decoded or manually constructed values are untrusted until this method succeeds.
Source§impl AllocationLedger
impl AllocationLedger
Sourcepub fn new(
ledger_schema_version: u32,
physical_format_id: u32,
current_generation: u64,
allocation_history: AllocationHistory,
) -> Result<Self, LedgerIntegrityError>
pub fn new( ledger_schema_version: u32, physical_format_id: u32, current_generation: u64, allocation_history: AllocationHistory, ) -> Result<Self, LedgerIntegrityError>
Build a ledger DTO and validate structural ledger invariants.
This constructor validates duplicate records, lifecycle state, record
generation bounds, and schema metadata records. It does not require a
complete committed-generation chain. Use
AllocationLedger::new_committed when constructing an authoritative
committed ledger DTO.
Sourcepub fn new_committed(
ledger_schema_version: u32,
physical_format_id: u32,
current_generation: u64,
allocation_history: AllocationHistory,
) -> Result<Self, LedgerIntegrityError>
pub fn new_committed( ledger_schema_version: u32, physical_format_id: u32, current_generation: u64, allocation_history: AllocationHistory, ) -> Result<Self, LedgerIntegrityError>
Build a committed ledger DTO and validate strict committed-history invariants.
This constructor runs the same committed-integrity checks used by recovery and commit. Use it when the value should be treated as an authoritative committed ledger, not merely as a structurally valid DTO.
Sourcepub const fn ledger_schema_version(&self) -> u32
pub const fn ledger_schema_version(&self) -> u32
Return the ledger schema version.
Sourcepub const fn physical_format_id(&self) -> u32
pub const fn physical_format_id(&self) -> u32
Return the protected physical format identifier.
Sourcepub const fn current_generation(&self) -> u64
pub const fn current_generation(&self) -> u64
Return the current committed generation selected by recovery.
Sourcepub const fn allocation_history(&self) -> &AllocationHistory
pub const fn allocation_history(&self) -> &AllocationHistory
Return the historical allocation facts.
Source§impl AllocationLedger
impl AllocationLedger
Sourcepub fn stage_validated_generation(
&self,
validated: &ValidatedAllocations,
committed_at: Option<u64>,
) -> Result<Self, AllocationStageError>
pub fn stage_validated_generation( &self, validated: &ValidatedAllocations, committed_at: Option<u64>, ) -> Result<Self, AllocationStageError>
Return a copy of the ledger with validated recorded as the next generation.
This is a pure logical update. Physical atomicity is the responsibility of the substrate commit protocol.
Sourcepub fn stage_reservation_generation(
&self,
reservations: &[AllocationDeclaration],
committed_at: Option<u64>,
) -> Result<Self, AllocationReservationError>
pub fn stage_reservation_generation( &self, reservations: &[AllocationDeclaration], committed_at: Option<u64>, ) -> Result<Self, AllocationReservationError>
Return a copy of the ledger with reservations recorded as the next generation.
This is a pure logical update. The caller is responsible for applying framework policy before staging reservations.
Sourcepub fn stage_retirement_generation(
&self,
retirement: &AllocationRetirement,
committed_at: Option<u64>,
) -> Result<Self, AllocationRetirementError>
pub fn stage_retirement_generation( &self, retirement: &AllocationRetirement, committed_at: Option<u64>, ) -> Result<Self, AllocationRetirementError>
Return a copy of the ledger with one explicit retirement committed.
Trait Implementations§
Source§impl Clone for AllocationLedger
impl Clone for AllocationLedger
Source§fn clone(&self) -> AllocationLedger
fn clone(&self) -> AllocationLedger
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AllocationLedger
impl Debug for AllocationLedger
Source§impl<'de> Deserialize<'de> for AllocationLedger
impl<'de> Deserialize<'de> for AllocationLedger
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for AllocationLedger
impl PartialEq for AllocationLedger
Source§fn eq(&self, other: &AllocationLedger) -> bool
fn eq(&self, other: &AllocationLedger) -> bool
self and other values to be equal, and is used by ==.