libiw_async/
err.rs

1use std::{error::Error, fmt::Display, io};
2
3#[derive(Debug, Clone)]
4pub enum IWError {
5    Unknown(String),
6    NotSupport(String),
7}
8
9impl Display for IWError {
10    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
11        match self {
12            IWError::Unknown(msg) => write!(f, "Unknown err: {}", msg),
13            IWError::NotSupport(msg) => write!(f, "NotSupport: {}", msg),
14        }
15    }
16}
17
18impl Error for IWError {}
19
20pub type Result<T = ()> = std::result::Result<T, IWError>;
21
22impl From<io::Error> for IWError {
23    fn from(value: io::Error) -> Self {
24        Self::Unknown(value.to_string())
25    }
26}