use thiserror::Error;
#[derive(Debug, Error, Clone, PartialEq)]
pub enum SparseError {
#[error("SV-1: indices ({indices}) and values ({values}) must have equal length")]
LengthMismatch { indices: usize, values: usize },
#[error(
"SV-2: indices must be strictly ascending (sorted + unique); violation at position {position} ({prev} >= {curr})"
)]
UnsortedIndices {
position: usize,
prev: u32,
curr: u32,
},
#[error("SV-3: weight at position {position} is non-finite ({value})")]
NonFiniteWeight { position: usize, value: f32 },
#[error("SV-4: encoded buffer truncated: need {need} bytes, got {got}")]
Truncated { need: usize, got: usize },
#[error("SV-5: encoded buffer has {trailing} unexpected trailing byte(s)")]
TrailingBytes { trailing: usize },
}