use std::fmt;
#[derive(Debug)]
pub enum TransportError {
Bind(String),
Send(String),
Io(String),
Unsupported(String),
}
impl fmt::Display for TransportError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
TransportError::Bind(msg) => write!(f, "udp bind error: {}", msg),
TransportError::Send(msg) => write!(f, "udp send error: {}", msg),
TransportError::Io(msg) => write!(f, "io error: {}", msg),
TransportError::Unsupported(msg) => write!(f, "unsupported transport: {}", msg),
}
}
}
impl std::error::Error for TransportError {}
impl From<std::io::Error> for TransportError {
fn from(err: std::io::Error) -> Self {
TransportError::Io(err.to_string())
}
}