linux_aio_tokio/
errors.rs

1use std::io;
2
3use thiserror::Error;
4
5use crate::eventfd::EventFdError;
6
7/// AIO command error
8#[derive(Error, Debug)]
9pub enum AioCommandError {
10    /// AIO context was stopped
11    #[error("AioContext stopped")]
12    AioStopped,
13
14    /// Error from [`io_submit`]
15    ///
16    /// [`io_submit`]: https://manpages.debian.org/testing/manpages-dev/io_submit.2.en.html
17    #[error("io_submit error: {0}")]
18    IoSubmit(#[source] io::Error),
19
20    /// Bad result received
21    #[error("bad result: `{0}`")]
22    BadResult(#[source] io::Error),
23
24    /// Non-zero length returned
25    #[error("non-zero code returned")]
26    NonZeroCode,
27
28    /// The capacity of AIO context exceeded. Happens if `use_semaphore` set to `false`
29    /// and the code attempts to send more requests than kernel-threads.
30    #[error("capacity exceeded")]
31    CapacityExceeded,
32}
33
34/// AIO context creation error
35#[derive(Error, Debug)]
36pub enum AioContextError {
37    /// Could not create [`EventFd`]
38    ///
39    /// [`EventFd`]: struct.EventFd.html
40    #[error("eventfd error: `{0}`")]
41    EventFd(#[from] EventFdError),
42
43    /// Error from `io_setup`
44    #[error("io_setup error: `{0}`")]
45    IoSetup(#[from] io::Error),
46}