xref: /xiu/protocol/rtsp/src/rtp/rtcp/errors.rs (revision 69de9bbd)
1 use bytesio::bytes_errors::BytesReadError;
2 use bytesio::bytes_errors::BytesWriteError;
3 use failure::Fail;
4 
5 #[derive(Debug)]
6 pub struct RtcpError {
7     pub value: RtcpErrorValue,
8 }
9 
10 #[derive(Debug, Fail)]
11 pub enum RtcpErrorValue {
12     #[fail(display = "bytes read error: {}", _0)]
13     BytesReadError(BytesReadError),
14     #[fail(display = "bytes write error: {}", _0)]
15     BytesWriteError(BytesWriteError),
16 }
17 
18 impl From<BytesReadError> for RtcpError {
from(error: BytesReadError) -> Self19     fn from(error: BytesReadError) -> Self {
20         RtcpError {
21             value: RtcpErrorValue::BytesReadError(error),
22         }
23     }
24 }
25 
26 impl From<BytesWriteError> for RtcpError {
from(error: BytesWriteError) -> Self27     fn from(error: BytesWriteError) -> Self {
28         RtcpError {
29             value: RtcpErrorValue::BytesWriteError(error),
30         }
31     }
32 }
33