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)]
ClockOutOfRange(#[from] broadcast_common::clock33::ClockOutOfRange),
#[error(transparent)]
FieldOverflow(#[from] broadcast_common::len::FieldOverflow),
#[error("packet has no adaptation field")]
NoAdaptationField,
#[error("packet has no {which} slot")]
NoClockReference {
which: &'static str,
},
#[error("adaptation field is {have} bytes, {need} needed")]
AdaptationFieldTooShort {
need: usize,
have: usize,
},
}