Skip to main content

dvb_cc/
error.rs

1//! Error type for cc_data parsing.
2
3/// Result alias.
4pub type Result<T> = core::result::Result<T, Error>;
5
6/// A cc_data parse error.
7#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
8#[non_exhaustive]
9pub enum Error {
10    /// Input shorter than required.
11    #[error("buffer too short: need {need}, have {have} ({what})")]
12    BufferTooShort {
13        /// Bytes required.
14        need: usize,
15        /// Bytes available.
16        have: usize,
17        /// What was being parsed.
18        what: &'static str,
19    },
20    /// Output buffer too small for serialization.
21    #[error("output buffer too small: need {need}, have {have}")]
22    OutputBufferTooSmall {
23        /// Bytes required.
24        need: usize,
25        /// Bytes available.
26        have: usize,
27    },
28    /// More than 31 triplets — cc_count is a 5-bit field.
29    #[error("too many cc triplets: {0} (cc_count is 5-bit, max 31)")]
30    TooManyTriplets(usize),
31}