Skip to main content

clark_hash/
error.rs

1use thiserror::Error;
2
3/// Result type used throughout the crate.
4pub type Result<T> = std::result::Result<T, SQuaJLError>;
5
6/// Error type for `clark-hash`.
7#[derive(Debug, Error)]
8pub enum SQuaJLError {
9    /// The provided configuration is invalid.
10    #[error("invalid configuration: {0}")]
11    InvalidConfig(String),
12    /// The input vector has the wrong dimension.
13    #[error("dimension mismatch: expected {expected}, got {actual}")]
14    DimensionMismatch {
15        /// Expected dimension.
16        expected: usize,
17        /// Actual dimension.
18        actual: usize,
19    },
20    /// The vector to encode or sketch was empty or had zero norm.
21    #[error("vector norm must be positive")]
22    ZeroNorm,
23    /// A quantized code does not match the codec configuration.
24    #[error("incompatible quantized vector: {0}")]
25    IncompatibleCode(String),
26    /// Backend integration failed.
27    #[cfg(feature = "fastembed")]
28    #[error("backend error: {0}")]
29    Backend(String),
30}