use thiserror::Error;
pub type Result<T> = core::result::Result<T, Error>;
#[derive(Debug, Error, PartialEq, Eq)]
#[non_exhaustive]
pub enum Error {
#[error("buffer too short: need {need} bytes, have {have} (while parsing {what})")]
BufferTooShort {
need: usize,
have: usize,
what: &'static str,
},
#[error("CRC-32 mismatch: computed {computed:#010x}, expected {expected:#010x}")]
CrcMismatch {
computed: u32,
expected: u32,
},
#[error("invalid TS sync byte: expected 0x47, got {found:#04x}")]
InvalidSyncByte {
found: u8,
},
#[error("serialize: output buffer too small — need {need}, have {have}")]
OutputBufferTooSmall {
need: usize,
have: usize,
},
#[error("section_length {declared} exceeds remaining buffer ({available} bytes)")]
SectionLengthOverflow {
declared: usize,
available: usize,
},
}