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("cdx block corrupted")]
40 CdxBlockCorrupted,
41
42 #[error("section offset out of bounds: {section} at {offset}+{size} > {file_len}")]
45 SectionOutOfBounds {
46 section: &'static str,
48 offset: u64,
50 size: u64,
52 file_len: u64,
54 },
55
56 #[error("truncated varint at position {0}")]
58 TruncatedVarint(usize),
59
60 #[error("varint overflow (> 10 bytes)")]
62 OverflowVarint,
63
64 #[error("posting list out of bounds")]
66 PostingOutOfBounds,
67
68 #[error("file_id {0} out of bounds")]
70 FileIdOutOfBounds(u32),
71
72 #[error("string pool offset out of bounds")]
74 StringPoolOutOfBounds,
75
76 #[error("invalid UTF-8 in path")]
78 InvalidPath,
79
80 #[error("regex: {0}")]
82 Regex(#[from] regex::Error),
83
84 #[cfg(feature = "notify")]
86 #[error("Watcher error: {0}")]
87 Watcher(#[from] notify::Error),
88
89 #[cfg(feature = "archive")]
91 #[error("Zip error: {0}")]
92 Zip(#[from] zip::result::ZipError),
93
94 #[error("config: {0}")]
96 Config(String),
97}
98
99pub type Result<T> = std::result::Result<T, Error>;