pub type Result<T> = core::result::Result<T, Error>;
#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
#[non_exhaustive]
pub enum Error {
#[error(transparent)]
BufferTooShort(#[from] broadcast_common::error::BufferTooShort),
#[error(transparent)]
OutputBufferTooSmall(#[from] broadcast_common::error::OutputBufferTooSmall),
#[error("bad data_identifier: {0:#04X} (expected 0x20)")]
BadDataIdentifier(u8),
#[error(transparent)]
InvalidSync(#[from] broadcast_common::error::InvalidSync),
#[error("bad end_of_PES_data_field_marker: {0:#04X} (expected 0xFF)")]
BadEndOfPesMarker(u8),
#[error("unknown segment_type: {0:#04X}")]
UnknownSegmentType(u8),
#[error("non-zero stuffing byte: {0:#04X} (expected 0x00)")]
BadStuffingByte(u8),
#[error("segment too large to serialize: segment_length oversized")]
SegmentTooLarge,
#[error(transparent)]
FieldOverflow(#[from] broadcast_common::len::FieldOverflow),
#[error("invalid subregion count: {0} (must be 1..=4)")]
InvalidSubregionCount(usize),
#[error("subregion position presence inconsistent with subregion count")]
SubregionPositionMismatch,
#[error("{extra} trailing byte(s) in {what}: not a whole entry ({entry_len} bytes each)")]
TrailingEntryBytes {
what: &'static str,
entry_len: usize,
extra: usize,
},
#[error(transparent)]
InvalidValue(#[from] broadcast_common::error::InvalidValue),
}