1use std::error::Error;
2use std::fmt;
3use std::io;
4
5pub use is::StunError;
6
7#[derive(Debug)]
9pub enum NetError {
10 Stun(StunError),
12
13 Io(io::Error),
15}
16
17impl fmt::Display for NetError {
18 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
19 match self {
20 NetError::Stun(err) => write!(f, "{}", err),
21 NetError::Io(err) => write!(f, "{}", err),
22 }
23 }
24}
25
26impl Error for NetError {
27 fn source(&self) -> Option<&(dyn Error + 'static)> {
28 match self {
29 NetError::Stun(err) => Some(err),
30 NetError::Io(err) => Some(err),
31 }
32 }
33}
34
35impl From<StunError> for NetError {
36 fn from(err: StunError) -> Self {
37 NetError::Stun(err)
38 }
39}
40
41impl From<io::Error> for NetError {
42 fn from(err: io::Error) -> Self {
43 NetError::Io(err)
44 }
45}