use std::io;
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("I/O error: {0}")]
Io(#[from] io::Error),
#[error("device name too long: {name} ({len} > 15 characters)")]
NameTooLong {
name: String,
len: usize,
},
#[error("invalid device name: {0}")]
InvalidName(String),
#[error("device already exists: {0}")]
DeviceExists(String),
#[error("device not found: {0}")]
DeviceNotFound(String),
#[error("permission denied: {0}")]
PermissionDenied(String),
#[error("user not found: {0}")]
UserNotFound(String),
#[error("group not found: {0}")]
GroupNotFound(String),
#[error("no mode specified (must be tun or tap)")]
NoModeSpecified,
#[error("ioctl {name} failed: {source}")]
Ioctl {
name: &'static str,
source: io::Error,
},
}
impl Error {
pub fn ioctl(name: &'static str, source: io::Error) -> Self {
Error::Ioctl { name, source }
}
}