use crate::{key::StableKey, physical::CommitRecoveryError, slot::MemoryManagerSlot};
#[non_exhaustive]
#[derive(Clone, Debug, Eq, thiserror::Error, PartialEq)]
pub enum LedgerIntegrityError {
#[error("ledger exceeds {resource} limit {limit}")]
LimitExceeded {
resource: &'static str,
limit: usize,
},
#[error("stable key '{stable_key}' appears in more than one allocation record")]
DuplicateStableKey { stable_key: StableKey },
#[error("allocation slot '{slot:?}' appears in more than one allocation record")]
DuplicateSlot { slot: MemoryManagerSlot },
#[error("genesis ledger contains allocation records")]
NonemptyGenesis,
}
#[non_exhaustive]
#[derive(Clone, Debug, Eq, thiserror::Error, PartialEq)]
pub enum LedgerCommitError {
#[error(transparent)]
Recovery(CommitRecoveryError),
#[error("allocation ledger codec failed: {0}")]
Codec(String),
#[error(transparent)]
Integrity(LedgerIntegrityError),
}
#[non_exhaustive]
#[derive(Clone, Debug, Eq, thiserror::Error, PartialEq)]
pub enum AllocationStageError {
#[error("ledger generation {generation} cannot be advanced without overflow")]
GenerationOverflow { generation: u64 },
#[error(transparent)]
Integrity(#[from] LedgerIntegrityError),
}