1#[derive(Debug, thiserror::Error)]
3pub enum WalError {
4 #[error("WAL I/O error: {0}")]
6 Io(#[from] std::io::Error),
7
8 #[error("WAL checksum mismatch at LSN {lsn}: expected {expected:#010x}, got {actual:#010x}")]
10 ChecksumMismatch {
11 lsn: u64,
12 expected: u32,
13 actual: u32,
14 },
15
16 #[error("invalid WAL magic at offset {offset}: expected {expected:#010x}, got {actual:#010x}")]
18 InvalidMagic {
19 offset: u64,
20 expected: u32,
21 actual: u32,
22 },
23
24 #[error("unsupported WAL format version {version} (supported: {supported})")]
26 UnsupportedVersion { version: u16, supported: u16 },
27
28 #[error("unknown required record type {record_type} at LSN {lsn}")]
31 UnknownRequiredRecordType { record_type: u16, lsn: u64 },
32
33 #[error("payload too large: {size} bytes (max: {max})")]
35 PayloadTooLarge { size: usize, max: usize },
36
37 #[error("WAL is sealed and no longer accepting writes")]
39 Sealed,
40
41 #[error("alignment violation: {context} (required: {required}, actual: {actual})")]
43 AlignmentViolation {
44 context: &'static str,
45 required: usize,
46 actual: usize,
47 },
48
49 #[error("WAL lock poisoned: {context}")]
51 LockPoisoned { context: &'static str },
52
53 #[error("WAL encryption error: {detail}")]
55 EncryptionError { detail: String },
56
57 #[error("DoubleWriteBuffer::open called with DwbMode::Off")]
60 DwbOffNotOpenable,
61
62 #[error("corrupt WAL record at LSN {lsn}: {detail}")]
66 CorruptRecord { lsn: u64, detail: String },
67}
68
69pub type Result<T> = std::result::Result<T, WalError>;