alpine_protocol_sdk/transport/
error.rs1use std::fmt;
2
3#[derive(Debug)]
4pub enum TransportError {
5 Bind(String),
6 Send(String),
7 Io(String),
8 Unsupported(String),
9}
10
11impl fmt::Display for TransportError {
12 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
13 match self {
14 TransportError::Bind(msg) => write!(f, "udp bind error: {}", msg),
15 TransportError::Send(msg) => write!(f, "udp send error: {}", msg),
16 TransportError::Io(msg) => write!(f, "io error: {}", msg),
17 TransportError::Unsupported(msg) => write!(f, "unsupported transport: {}", msg),
18 }
19 }
20}
21
22impl std::error::Error for TransportError {}
23
24impl From<std::io::Error> for TransportError {
25 fn from(err: std::io::Error) -> Self {
26 TransportError::Io(err.to_string())
27 }
28}