rswifi/
error.rs

1
2#[derive(Debug, thiserror::Error)]
3pub enum Error {
4    #[error("IO error: {0:?}")]
5    IoError(std::io::Error),
6    #[error("Os error: {0}")]
7    OsError(String),
8    #[error("{}", _0)]
9    Other(Box<dyn std::error::Error + Send + Sync>),
10}
11
12impl From<std::io::Error> for Error {
13    #[inline]
14    fn from(e: std::io::Error) -> Self {
15        Self::IoError(e)
16    }
17}
18
19#[cfg(target_os = "linux")]
20impl From<nix::errno::Errno> for Error {
21    #[inline]
22    fn from(e: nix::errno::Errno) -> Self {
23        Self::OsError(format!("{}", e))
24    }
25}
26
27#[cfg(target_os = "linux")]
28impl From<std::ffi::OsString> for Error {
29    #[inline]
30    fn from(s: std::ffi::OsString) -> Self {
31        Self::OsError(format!("{:?}", s))
32    }
33}
34
35
36#[cfg(target_os = "windows")]
37impl From<windows::core::Error> for Error {
38    #[inline]
39    fn from(e: windows::core::Error) -> Self {
40        Self::OsError(format!("{}", e))
41    }
42}