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("checkpoint frame corrupt at {path}: {detail}")]
20 CheckpointCorrupt { path: String, detail: String },
21
22 #[error("invalid WAL magic at offset {offset}: expected {expected:#010x}, got {actual:#010x}")]
24 InvalidMagic {
25 offset: u64,
26 expected: u32,
27 actual: u32,
28 },
29
30 #[error("unsupported WAL format version {version} (supported: {supported})")]
32 UnsupportedVersion { version: u16, supported: u16 },
33
34 #[error("unknown required record type {record_type} at LSN {lsn}")]
37 UnknownRequiredRecordType { record_type: u32, lsn: u64 },
38
39 #[error("payload too large: {size} bytes (max: {max})")]
41 PayloadTooLarge { size: usize, max: usize },
42
43 #[error("WAL is sealed and no longer accepting writes")]
45 Sealed,
46
47 #[error("alignment violation: {context} (required: {required}, actual: {actual})")]
49 AlignmentViolation {
50 context: &'static str,
51 required: usize,
52 actual: usize,
53 },
54
55 #[error("WAL lock poisoned: {context}")]
57 LockPoisoned { context: &'static str },
58
59 #[error("WAL encryption error: {detail}")]
61 EncryptionError { detail: String },
62
63 #[error("DoubleWriteBuffer::open called with DwbMode::Off")]
66 DwbOffNotOpenable,
67
68 #[error("corrupt WAL record at LSN {lsn}: {detail}")]
72 CorruptRecord { lsn: u64, detail: String },
73
74 #[error("invalid WAL payload: {detail}")]
78 InvalidPayload { detail: String },
79
80 #[error("WAL operation not supported on this platform: {detail}")]
82 Unsupported { detail: &'static str },
83}
84
85pub type Result<T> = std::result::Result<T, WalError>;