Skip to main content

ringline/
error.rs

1use std::io;
2
3use thiserror::Error;
4
5/// Errors returned by the ringline driver.
6#[derive(Debug, Error)]
7pub enum Error {
8    /// io_uring setup or operation failed.
9    #[error("I/O error: {0}")]
10    Io(#[from] io::Error),
11    /// Ring setup failed (e.g., unsupported kernel features).
12    #[error("ring setup: {0}")]
13    RingSetup(String),
14    /// Buffer registration failed.
15    #[error("buffer registration: {0}")]
16    BufferRegistration(String),
17    /// No free connection slots available.
18    #[error("connection limit reached")]
19    ConnectionLimitReached,
20    /// Invalid connection token (stale or out of range).
21    #[error("invalid connection")]
22    InvalidConnection,
23    /// No send pool slots available.
24    #[error("send pool exhausted")]
25    SendPoolExhausted,
26    /// Invalid memory region ID.
27    #[error("invalid memory region ID")]
28    InvalidRegion,
29    /// Pointer not within the specified registered region.
30    #[error("pointer not within registered region")]
31    PointerOutOfRegion,
32    /// System resource limit too low (e.g., RLIMIT_NOFILE).
33    #[error("{0}")]
34    ResourceLimit(String),
35}
36
37/// Errors returned by UDP send operations.
38#[derive(Debug, Error)]
39pub enum UdpSendError {
40    /// No free send slot or copy-pool slot available (try again after a CQE).
41    #[error("UDP send pool exhausted")]
42    PoolExhausted,
43    /// UDP submission queue full.
44    #[error("UDP submission queue full")]
45    SubmissionQueueFull,
46    /// UDP I/O error.
47    #[error("UDP I/O error: {0}")]
48    Io(#[from] io::Error),
49}
50
51/// Error returned by [`try_sleep`](crate::try_sleep) and
52/// [`try_timeout`](crate::try_timeout) when the timer slot pool is full.
53#[derive(Debug, Clone, PartialEq, Eq, Error)]
54#[error("timer slot pool exhausted")]
55pub struct TimerExhausted;