xref: /xiu/protocol/rtsp/src/rtp/rtcp/errors.rs (revision 69de9bbd)
18e71d710SHarlan use bytesio::bytes_errors::BytesReadError;
28e71d710SHarlan use bytesio::bytes_errors::BytesWriteError;
38e71d710SHarlan use failure::Fail;
48e71d710SHarlan 
58e71d710SHarlan #[derive(Debug)]
68e71d710SHarlan pub struct RtcpError {
78e71d710SHarlan     pub value: RtcpErrorValue,
88e71d710SHarlan }
98e71d710SHarlan 
108e71d710SHarlan #[derive(Debug, Fail)]
118e71d710SHarlan pub enum RtcpErrorValue {
12*69de9bbdSHarlanC     #[fail(display = "bytes read error: {}", _0)]
138e71d710SHarlan     BytesReadError(BytesReadError),
14*69de9bbdSHarlanC     #[fail(display = "bytes write error: {}", _0)]
158e71d710SHarlan     BytesWriteError(BytesWriteError),
168e71d710SHarlan }
178e71d710SHarlan 
188e71d710SHarlan impl From<BytesReadError> for RtcpError {
from(error: BytesReadError) -> Self198e71d710SHarlan     fn from(error: BytesReadError) -> Self {
208e71d710SHarlan         RtcpError {
218e71d710SHarlan             value: RtcpErrorValue::BytesReadError(error),
228e71d710SHarlan         }
238e71d710SHarlan     }
248e71d710SHarlan }
258e71d710SHarlan 
268e71d710SHarlan impl From<BytesWriteError> for RtcpError {
from(error: BytesWriteError) -> Self278e71d710SHarlan     fn from(error: BytesWriteError) -> Self {
288e71d710SHarlan         RtcpError {
298e71d710SHarlan             value: RtcpErrorValue::BytesWriteError(error),
308e71d710SHarlan         }
318e71d710SHarlan     }
328e71d710SHarlan }
33