chronix_encoding/error.rs
1//! Encoding error types.
2
3use thiserror::Error;
4
5/// Errors that can occur during encoding or decoding.
6#[derive(Debug, Clone, PartialEq, Eq, Error)]
7pub enum EncodingError {
8 /// The input data is empty.
9 #[error("empty input: {context}")]
10 EmptyInput {
11 /// Description of which encoder received empty input.
12 context: &'static str,
13 },
14
15 /// The encoded data is truncated or malformed.
16 #[error("corrupt encoded data: {detail}")]
17 CorruptData {
18 /// Human-readable description of the corruption.
19 detail: String,
20 },
21
22 /// An unsupported encoding type was encountered.
23 #[error("unsupported encoding type tag: {tag}")]
24 UnsupportedEncoding {
25 /// The unknown encoding type discriminant.
26 tag: u8,
27 },
28
29 /// Value count mismatch between null bitmap and data.
30 #[error("value count mismatch: expected {expected}, got {actual}")]
31 CountMismatch {
32 /// Expected number of values.
33 expected: usize,
34 /// Actual number of values.
35 actual: usize,
36 },
37
38 /// Dictionary overflow — too many unique values.
39 #[error("dictionary overflow: {count} unique values exceed limit of {limit}")]
40 DictionaryOverflow {
41 /// Actual number of unique values.
42 count: usize,
43 /// Maximum allowed unique values.
44 limit: usize,
45 },
46}
47
48/// A specialized `Result` type for encoding operations.
49pub type Result<T> = std::result::Result<T, EncodingError>;