Skip to main content

chronix_engine/index/
error.rs

1//! Index error types.
2
3use thiserror::Error;
4
5/// Indexing errors.
6#[derive(Debug, Error)]
7pub enum IndexError {
8    /// Underlying I/O error.
9    #[error("Index I/O error: {0}")]
10    Io(#[from] std::io::Error),
11
12    /// Segment not found in the catalog.
13    #[error("Segment not found in catalog: {0}")]
14    SegmentNotFound(u64),
15
16    /// Corrupt index data.
17    #[error("Corrupt index: {detail}")]
18    Corrupt {
19        /// Description of the corruption.
20        detail: String,
21    },
22
23    /// The on-disk data belongs to a different format generation.
24    ///
25    /// Deliberately distinct from [`Corrupt`](Self::Corrupt): the bytes are
26    /// intact and the reader is from another generation, so the remedy is to
27    /// match the versions up rather than to restore from a backup. The two
28    /// used to be one variant, which sent an operator who had upgraded
29    /// looking for a failing disk.
30    #[error("{detail}")]
31    UnsupportedVersion {
32        /// What was read, what this build expects, and what to do.
33        detail: String,
34    },
35
36    /// Binary (postcard) serialization error.
37    #[error("Binary serialization error: {0}")]
38    BinarySerialization(String),
39
40    /// Manifest replay error.
41    #[error("Manifest error: {detail}")]
42    Manifest {
43        /// Description of the manifest error.
44        detail: String,
45    },
46}
47
48/// A specialized `Result` type for index operations.
49pub type Result<T> = std::result::Result<T, IndexError>;