1pub type Result<T> = std::result::Result<T, Error>;
4
5#[derive(Debug, thiserror::Error)]
7pub enum Error {
8 #[error("the selected mode does not allow for this operation")]
9 InvalidMode,
10 #[error("failed to initialise socket: invalid address")]
11 InvalidAddr,
12 #[error("failed to send packet!")]
13 FailedToSend,
14}
15
16impl From<async_std::io::Error> for Error {
17 fn from(e: async_std::io::Error) -> Self {
18 use async_std::io::ErrorKind::*;
19 match e.kind() {
20 PermissionDenied | AddrInUse | AddrNotAvailable => Self::InvalidAddr,
21 e => panic!("Unhandled io error: `{:?}`", e),
22 }
23 }
24}