use crate::burst::DataMode;
pub type Result<T> = core::result::Result<T, Error>;
#[derive(Debug, Clone, Copy, PartialEq, Eq, thiserror::Error)]
#[non_exhaustive]
pub enum Error {
#[error("buffer too short: need {need}, have {have} ({what})")]
BufferTooShort {
need: usize,
have: usize,
what: &'static str,
},
#[error(
"invalid {word} sync value: expected {expected:#06x}, found {found:#06x} \
(SMPTE ST 337 Table 6)"
)]
InvalidSync {
word: &'static str,
expected: u16,
found: u16,
},
#[error("field {field} value {value} invalid: {reason}")]
InvalidValue {
field: &'static str,
value: u64,
reason: &'static str,
},
#[error(
"data_mode {0:?} is not supported by this crate (only Mode16 -- \
see docs/st337.md scope decision 2)"
)]
UnsupportedDataMode(DataMode),
#[error(
"data_type {data_type} requires the six-word preamble (Pe/Pf) to be \
{expected_extended}, but it was {found_extended}"
)]
ExtendedPreambleMismatch {
data_type: u8,
expected_extended: bool,
found_extended: bool,
},
#[error(
"burst_payload of {payload_bits} bits ({extended_offset_bits} extended-preamble bits \
included) exceeds the 16-bit-mode length_code maximum of 65535 bits"
)]
PayloadTooLarge {
payload_bits: u32,
extended_offset_bits: u32,
},
}