netmap_rs/
error.rs

1use std::io;
2use thiserror::Error;
3
4/// Errors that can occur when working with Netmap
5
6#[derive(Error, Debug)]
7pub enum Error {
8    /// I/O error from the underlying system
9    #[error("I/O error: {0}")]
10    Io(#[from] io::Error),
11
12    /// operation would block
13    #[error("Operation would block")]
14    WouldBlock,
15
16    /// binding interface failed
17    #[error("Failed to bind to inteface: {0}")]
18    BindFail(String),
19
20    /// Invalid ring index
21    #[error("Invalid ring index: {0}")]
22    InvalidRingIndex(usize),
23
24    /// Packet too large for ring buffer
25    #[error("Packet too large for ring buffer: {0} bytes")]
26    PacketTooLarge(usize),
27
28    /// Not enough space in ring buffer
29    #[error("Not  enough space inring buffer")]
30    InsufficientSpace,
31
32    /// Platform not yet supported
33    #[error("Platform not yet supported: {0}")]
34    UnsupportedPlatform(String),
35
36    /// Feature not  supported in fallback mode
37    #[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}