Skip to main content

ruvector_crv/
error.rs

1//! Error types for the CRV protocol integration.
2
3use thiserror::Error;
4
5/// CRV-specific errors.
6#[derive(Debug, Error)]
7pub enum CrvError {
8    /// Dimension mismatch between expected and actual vector sizes.
9    #[error("Dimension mismatch: expected {expected}, got {actual}")]
10    DimensionMismatch { expected: usize, actual: usize },
11
12    /// Invalid CRV stage number.
13    #[error("Invalid stage: {0} (must be 1-6)")]
14    InvalidStage(u8),
15
16    /// Empty input data.
17    #[error("Empty input: {0}")]
18    EmptyInput(String),
19
20    /// Session not found.
21    #[error("Session not found: {0}")]
22    SessionNotFound(String),
23
24    /// Encoding failure.
25    #[error("Encoding error: {0}")]
26    EncodingError(String),
27
28    /// Attention mechanism error.
29    #[error("Attention error: {0}")]
30    AttentionError(#[from] ruvector_attention::AttentionError),
31
32    /// Serialization error.
33    #[error("Serialization error: {0}")]
34    SerializationError(#[from] serde_json::Error),
35}
36
37/// Result type alias for CRV operations.
38pub type CrvResult<T> = Result<T, CrvError>;