|
| 1 | +//! io_uring RingBuf Errors |
| 2 | +
|
| 3 | +use core::fmt; |
| 4 | +use core::fmt::Display; |
| 5 | + |
| 6 | +use anonymous_mmap::AnonymousMmapError; |
| 7 | + |
| 8 | +/// Errors from the UringRingBuf |
| 9 | +#[derive(Debug)] |
| 10 | +pub enum RingBufError { |
| 11 | + /// Given / assumed page size must be divisible with the given buffer size |
| 12 | + PageSizeUndivisible, |
| 13 | + /// Error during Mmap from AnonymousMmap |
| 14 | + Mmap(AnonymousMmapError), |
| 15 | + /// io-uring-bearer Related Unregister error |
| 16 | + #[cfg(feature = "bearer")] |
| 17 | + Unregister(crate::RingBufRegistered, std::io::Error), |
| 18 | + /// io-uring-bearer Related Register error |
| 19 | + #[cfg(feature = "bearer")] |
| 20 | + Register(crate::RingBufUnregistered, std::io::Error), |
| 21 | +} |
| 22 | + |
| 23 | +impl Display for RingBufError { |
| 24 | + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
| 25 | + match self { |
| 26 | + Self::PageSizeUndivisible => write!(f, "Given / assumed page size must be divisible with the given buffer size"), |
| 27 | + Self::Mmap(am) => write!(f, "mmap error: {}", am), |
| 28 | + #[cfg(feature = "bearer")] |
| 29 | + Self::Register(_, iou) => write!(f, "IoUring Register: {}", iou), |
| 30 | + #[cfg(feature = "bearer")] |
| 31 | + Self::Unregister(_, iou) => write!(f, "IoUring Unregister: {}", iou), |
| 32 | + } |
| 33 | + } |
| 34 | +} |
| 35 | + |
| 36 | +impl core::error::Error for RingBufError {} |
0 commit comments