1#[derive(Debug, thiserror::Error)]
3pub enum Error {
4 #[error("I/O: {0}")]
6 Io(#[from] std::io::Error),
7
8 #[error("index too small (< 256 bytes)")]
10 IndexTooSmall,
11
12 #[error("bad magic (expected IX01)")]
14 BadMagic,
15
16 #[error("unsupported version {major}.{minor}")]
18 UnsupportedVersion {
19 major: u16,
21 minor: u16,
23 },
24
25 #[error("header CRC mismatch (expected {expected:#010x}, got {actual:#010x})")]
27 HeaderCorrupted {
28 expected: u32,
30 actual: u32,
32 },
33
34 #[error("posting list corrupted (CRC mismatch)")]
36 PostingCorrupted,
37
38 #[error("section offset out of bounds: {section} at {offset}+{size} > {file_len}")]
40 SectionOutOfBounds {
41 section: &'static str,
43 offset: u64,
45 size: u64,
47 file_len: u64,
49 },
50
51 #[error("truncated varint at position {0}")]
53 TruncatedVarint(usize),
54
55 #[error("varint overflow (> 10 bytes)")]
57 OverflowVarint,
58
59 #[error("posting list out of bounds")]
61 PostingOutOfBounds,
62
63 #[error("file_id {0} out of bounds")]
65 FileIdOutOfBounds(u32),
66
67 #[error("string pool offset out of bounds")]
69 StringPoolOutOfBounds,
70
71 #[error("invalid UTF-8 in path")]
73 InvalidPath,
74
75 #[error("regex: {0}")]
77 Regex(#[from] regex::Error),
78
79 #[cfg(feature = "notify")]
81 #[error("Watcher error: {0}")]
82 Watcher(#[from] notify::Error),
83
84 #[cfg(feature = "archive")]
86 #[error("Zip error: {0}")]
87 Zip(#[from] zip::result::ZipError),
88
89 #[error("config: {0}")]
91 Config(String),
92}
93
94pub type Result<T> = std::result::Result<T, Error>;