1#[derive(Debug, thiserror::Error)]
5pub enum WalError {
6 #[error("WAL I/O error: {0}")]
8 Io(#[from] std::io::Error),
9
10 #[error("WAL checksum mismatch at LSN {lsn}: expected {expected:#010x}, got {actual:#010x}")]
12 ChecksumMismatch {
13 lsn: u64,
14 expected: u32,
15 actual: u32,
16 },
17
18 #[error("invalid WAL magic at offset {offset}: expected {expected:#010x}, got {actual:#010x}")]
20 InvalidMagic {
21 offset: u64,
22 expected: u32,
23 actual: u32,
24 },
25
26 #[error("unsupported WAL format version {version} (supported: {supported})")]
28 UnsupportedVersion { version: u16, supported: u16 },
29
30 #[error("unknown required record type {record_type} at LSN {lsn}")]
33 UnknownRequiredRecordType { record_type: u32, lsn: u64 },
34
35 #[error("payload too large: {size} bytes (max: {max})")]
37 PayloadTooLarge { size: usize, max: usize },
38
39 #[error("WAL is sealed and no longer accepting writes")]
41 Sealed,
42
43 #[error("alignment violation: {context} (required: {required}, actual: {actual})")]
45 AlignmentViolation {
46 context: &'static str,
47 required: usize,
48 actual: usize,
49 },
50
51 #[error("WAL lock poisoned: {context}")]
53 LockPoisoned { context: &'static str },
54
55 #[error("WAL encryption error: {detail}")]
57 EncryptionError { detail: String },
58
59 #[error("DoubleWriteBuffer::open called with DwbMode::Off")]
62 DwbOffNotOpenable,
63
64 #[error("corrupt WAL record at LSN {lsn}: {detail}")]
68 CorruptRecord { lsn: u64, detail: String },
69
70 #[error("invalid WAL payload: {detail}")]
74 InvalidPayload { detail: String },
75}
76
77pub type Result<T> = std::result::Result<T, WalError>;