kimberlite_storage/
error.rs1use std::io;
4
5use kimberlite_crypto::ChainHash;
6use kimberlite_types::Offset;
7
8#[derive(thiserror::Error, Debug)]
10pub enum StorageError {
11 #[error("error writing batch payload")]
13 WriteError,
14
15 #[error("filesystem error: {0}")]
17 Io(#[from] io::Error),
18
19 #[error("unexpected end of file")]
21 UnexpectedEof,
22
23 #[error("corrupted record: CRC mismatch")]
25 CorruptedRecord,
26
27 #[error("torn write detected: {reason}")]
32 TornWrite { reason: String },
33
34 #[error("invalid record kind byte {byte:#04x} at offset {offset}")]
36 InvalidRecordKind { byte: u8, offset: Offset },
37
38 #[error(
40 "hash chain verification failed at offset {offset}: expected {expected:?}, found {actual:?}"
41 )]
42 ChainVerificationFailed {
43 offset: Offset,
44 expected: Option<ChainHash>,
45 actual: Option<ChainHash>,
46 },
47
48 #[error("invalid checkpoint payload at offset {offset}: {reason}")]
50 InvalidCheckpointPayload { offset: Offset, reason: String },
51
52 #[error("invalid index magic bytes")]
54 InvalidIndexMagic,
55
56 #[error("unsupported index version: {0}")]
58 UnsupportedIndexVersion(u8),
59
60 #[error("index checksum mismatch: expected {expected:#010x}, got {actual:#010x}")]
62 IndexChecksumMismatch { expected: u32, actual: u32 },
63
64 #[error("truncated index file: expected {expected} bytes, got {actual}")]
66 IndexTruncated { expected: usize, actual: usize },
67
68 #[error("{codec} compression failed: {reason}")]
70 CompressionFailed { codec: &'static str, reason: String },
71
72 #[error("{codec} decompression failed: {reason}")]
74 DecompressionFailed { codec: &'static str, reason: String },
75
76 #[error("invalid compression kind byte {byte:#04x} at offset {offset}")]
78 InvalidCompressionKind { byte: u8, offset: Offset },
79}