#[derive(Debug, thiserror::Error)]
pub enum WalError {
#[error("WAL I/O error: {0}")]
Io(#[from] std::io::Error),
#[error("WAL checksum mismatch at LSN {lsn}: expected {expected:#010x}, got {actual:#010x}")]
ChecksumMismatch {
lsn: u64,
expected: u32,
actual: u32,
},
#[error("invalid WAL magic at offset {offset}: expected {expected:#010x}, got {actual:#010x}")]
InvalidMagic {
offset: u64,
expected: u32,
actual: u32,
},
#[error("unsupported WAL format version {version} (supported: {supported})")]
UnsupportedVersion { version: u16, supported: u16 },
#[error("unknown required record type {record_type} at LSN {lsn}")]
UnknownRequiredRecordType { record_type: u16, lsn: u64 },
#[error("payload too large: {size} bytes (max: {max})")]
PayloadTooLarge { size: usize, max: usize },
#[error("WAL is sealed and no longer accepting writes")]
Sealed,
#[error("alignment violation: {context} (required: {required}, actual: {actual})")]
AlignmentViolation {
context: &'static str,
required: usize,
actual: usize,
},
#[error("WAL lock poisoned: {context}")]
LockPoisoned { context: &'static str },
#[error("WAL encryption error: {detail}")]
EncryptionError { detail: String },
}
pub type Result<T> = std::result::Result<T, WalError>;