use thiserror::Error;
#[derive(Error, Debug, PartialEq)]
pub enum Error {
#[error("Wrong marshal size")]
WrongMarshalSize,
#[error("Invalid total lost count")]
InvalidTotalLost,
#[error("Invalid header")]
InvalidHeader,
#[error("Empty compound packet")]
EmptyCompound,
#[error("First packet in compound must be SR or RR")]
BadFirstPacket,
#[error("Compound missing SourceDescription with CNAME")]
MissingCname,
#[error("Feedback packet seen before CNAME")]
PacketBeforeCname,
#[error("Too many reports")]
TooManyReports,
#[error("Too many chunks")]
TooManyChunks,
#[error("too many sources")]
TooManySources,
#[error("Packet status chunk must be 2 bytes")]
PacketTooShort,
#[error("Buffer too short to be written")]
BufferTooShort,
#[error("Wrong packet type")]
WrongType,
#[error("SDES must be < 255 octets long")]
SdesTextTooLong,
#[error("SDES item missing type")]
SdesMissingType,
#[error("Reason must be < 255 octets long")]
ReasonTooLong,
#[error("Invalid packet version")]
BadVersion,
#[error("Invalid padding value")]
WrongPadding,
#[error("Wrong feedback message type")]
WrongFeedbackType,
#[error("Wrong payload type")]
WrongPayloadType,
#[error("Header length is too small")]
HeaderTooSmall,
#[error("Media SSRC must be 0")]
SsrcMustBeZero,
#[error("Missing REMB identifier")]
MissingRembIdentifier,
#[error("SSRC num and length do not match")]
SsrcNumAndLengthMismatch,
#[error("Invalid size or startIndex")]
InvalidSizeOrStartIndex,
#[error("Delta exceed limit")]
DeltaExceedLimit,
#[error("Packet status chunk must be 2 bytes")]
PacketStatusChunkLength,
#[allow(non_camel_case_types)]
#[error("{0}")]
new(String),
}
impl Error {
pub fn equal(&self, err: &anyhow::Error) -> bool {
err.downcast_ref::<Self>().map_or(false, |e| e == self)
}
}