libiw_async/
err.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
use std::{error::Error, fmt::Display, io};

#[derive(Debug, Clone)]
pub enum IWError {
    Unknown(String),
    NotSupport(String),
}

impl Display for IWError {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            IWError::Unknown(msg) => write!(f, "Unknown err: {}", msg),
            IWError::NotSupport(msg) => write!(f, "NotSupport: {}", msg),
        }
    }
}

impl Error for IWError {}

pub type Result<T = ()> = std::result::Result<T, IWError>;

impl From<io::Error> for IWError {
    fn from(value: io::Error) -> Self {
        Self::Unknown(value.to_string())
    }
}