use std::io;
use thiserror::Error;
#[derive(Error, Debug)]
pub enum Error {
#[error("I/O error: {0}")]
Io(#[from] io::Error),
#[error("Operation would block")]
WouldBlock,
#[error("Failed to bind to interface: {0}")]
BindFail(String),
#[error("Invalid ring index: {0}")]
InvalidRingIndex(usize),
#[error("Packet too large for ring buffer: {0} bytes")]
PacketTooLarge(usize),
#[error("Not enough space in ring buffer")]
InsufficientSpace,
#[error("Platform not yet supported: {0}")]
UnsupportedPlatform(String),
#[error("Feature not supported in fallback mode: {0}")]
FallbackUnsupported(String),
}
impl From<Error> for io::Error {
fn from(err: Error) -> io::Error {
match err {
Error::Io(e) => e,
e => io::Error::new(io::ErrorKind::Other, e.to_string()),
}
}
}