use thiserror::Error;
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Error, Debug, PartialEq)]
#[non_exhaustive]
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,
#[error("Invalid bitrate")]
InvalidBitrate,
#[error("Wrong chunk type")]
WrongChunkType,
#[error("Struct contains unexpected member type")]
BadStructMemberType,
#[error("Cannot read into non-pointer")]
BadReadParameter,
#[error("{0}")]
Util(#[from] util::Error),
#[error("{0}")]
Other(String),
}
impl From<Error> for util::Error {
fn from(e: Error) -> Self {
util::Error::from_std(e)
}
}
impl PartialEq<util::Error> for Error {
fn eq(&self, other: &util::Error) -> bool {
if let Some(down) = other.downcast_ref::<Error>() {
return self == down;
}
false
}
}