use thiserror::Error;
pub type Result<T> = core::result::Result<T, Error>;
#[derive(Debug, Error, PartialEq, Eq, Clone)]
#[non_exhaustive]
pub enum Error {
#[error(transparent)]
BufferTooShort(#[from] broadcast_common::error::BufferTooShort),
#[error(transparent)]
CrcMismatch(#[from] broadcast_common::error::CrcMismatch),
#[error(transparent)]
InvalidSync(#[from] broadcast_common::error::InvalidSync),
#[error(transparent)]
OutputBufferTooSmall(#[from] broadcast_common::error::OutputBufferTooSmall),
#[error("section_length {declared} exceeds remaining buffer ({available} bytes)")]
SectionLengthOverflow {
declared: usize,
available: usize,
},
#[error("payload {len} bytes exceeds the {max}-byte TS packet payload capacity")]
PayloadTooLarge {
len: usize,
max: usize,
},
#[error(transparent)]
FieldOverflow(#[from] broadcast_common::len::FieldOverflow),
#[error(
"section payload is {actual} bytes but section_length ({section_length}) implies {expected}"
)]
SectionPayloadLengthMismatch {
section_length: u16,
expected: usize,
actual: usize,
},
}