1use std::io;
2use thiserror::Error;
3
4#[derive(Error, Debug)]
7pub enum Error {
8 #[error("I/O error: {0}")]
10 Io(#[from] io::Error),
11
12 #[error("Operation would block")]
14 WouldBlock,
15
16 #[error("Failed to bind to inteface: {0}")]
18 BindFail(String),
19
20 #[error("Invalid ring index: {0}")]
22 InvalidRingIndex(usize),
23
24 #[error("Packet too large for ring buffer: {0} bytes")]
26 PacketTooLarge(usize),
27
28 #[error("Not enough space inring buffer")]
30 InsufficientSpace,
31
32 #[error("Platform not yet supported: {0}")]
34 UnsupportedPlatform(String),
35
36 #[error("Feature not supported in fallback mode: {0}")]
38 FallbackUnsupported(String),
39}
40
41impl From<Error> for io::Error {
42 fn from(err: Error) -> io::Error {
43 match err {
44 Error::Io(e) => e,
45 e => io::Error::other(e),
46 }
47 }
48}