Skip to main content

sochdb_vector/
error.rs

1//! Error types for the vector search engine.
2
3use thiserror::Error;
4
5/// Main error type for the engine
6#[derive(Error, Debug)]
7pub enum Error {
8    #[error("IO error: {0}")]
9    Io(#[from] std::io::Error),
10
11    #[error("Storage error: {0}")]
12    Storage(String),
13
14    #[error("Segment error: {0}")]
15    Segment(String),
16
17    #[error("Invalid segment magic: expected SVSEGM")]
18    InvalidMagic,
19
20    #[error("Unsupported segment version: {0}")]
21    UnsupportedVersion(u32),
22
23    #[error("Dimension mismatch: expected {expected}, got {got}")]
24    DimensionMismatch { expected: u32, got: u32 },
25
26    #[error("Vector ID out of range: {0}")]
27    VectorIdOutOfRange(u32),
28
29    #[error("Segment not found: {0}")]
30    SegmentNotFound(u64),
31
32    #[error("Collection not found: {0}")]
33    CollectionNotFound(String),
34
35    #[error("Catalog error: {0}")]
36    Catalog(String),
37
38    #[error("Query error: {0}")]
39    Query(String),
40
41    #[error("Configuration error: {0}")]
42    Config(String),
43
44    #[error("Serialization error: {0}")]
45    Serialization(String),
46
47    #[error("Kernel dispatch error: {0}")]
48    KernelDispatch(String),
49
50    #[error("Compaction error: {0}")]
51    Compaction(String),
52
53    #[error("Filter error: {0}")]
54    Filter(String),
55
56    #[error("Index is empty")]
57    EmptyIndex,
58}
59
60/// Result type alias
61pub type Result<T> = std::result::Result<T, Error>;
62
63impl From<bincode::Error> for Error {
64    fn from(e: bincode::Error) -> Self {
65        Error::Serialization(e.to_string())
66    }
67}