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 RTP version: {0} (RFC 3550 §5.1 requires version 2)")]
InvalidVersion(u8),
#[error("field {field} value {value} invalid: {reason}")]
InvalidValue {
field: &'static str,
value: u64,
reason: &'static str,
},
#[error("invalid padding: count {count} ({reason})")]
InvalidPadding {
count: u8,
reason: &'static str,
},
#[error(
"header extension data length {data_len} is not a multiple of 4 bytes \
(RFC 3550 §5.3.1: length counts 32-bit words)"
)]
ExtensionNotWordAligned {
data_len: usize,
},
#[cfg(feature = "rfc8285")]
#[error(
"profile_id {profile_id:#06x} matches neither the RFC 8285 one-byte \
(0xBEDE) nor two-byte (0x1000-0x100F) header-extension form"
)]
NotRfc8285Extension {
profile_id: u16,
},
#[cfg(feature = "rfc8285")]
#[error(
"invalid RFC 8285 one-byte extension element id {0} (valid range is 1..=14; \
0 is reserved for padding, 15 is reserved)"
)]
InvalidOneByteExtensionId(u8),
#[cfg(feature = "rfc8285")]
#[error(
"invalid RFC 8285 two-byte extension element id 0 (reserved for padding \
in both forms, per RFC 8285 §4.1.2/§5)"
)]
InvalidTwoByteExtensionId,
}