tidy_tuntap/
error.rs

1use std::io;
2
3pub type Result<T> = std::result::Result<T, Error>;
4
5#[derive(Debug, thiserror::Error)]
6pub enum Error {
7    #[error("Device count must be greater than zero")]
8    ZeroDevices,
9
10    #[error("IO error: {0}")]
11    IOError(#[from] io::Error),
12
13    #[error("Nix error: {0}")]
14    NixError(#[from] nix::Error),
15
16    #[error("Failed to create Flags from the data returned by the kernel: {0:b}")]
17    ConversionError(i32),
18}
19
20impl From<Error> for io::Error {
21    fn from(err: Error) -> Self {
22        match err {
23            Error::IOError(io_err) => io_err,
24            _ => io::Error::new(io::ErrorKind::Other, err),
25        }
26    }
27}