Skip to main content

externally_driven_async_rt/event_loop/
error.rs

1/// An error that can be returned from an [`EventLoop`](crate::EventLoop).
2#[derive(Debug, Clone, Copy, PartialEq, Eq)]
3pub enum Error {
4    /// An epoll or kqueue call failed.
5    Io(rustix::io::Errno),
6    /// [`EventLoop::drain_events_without_blocking`](crate::EventLoop::drain_events_without_blocking)
7    /// is called on the [`EventLoop`](crate::EventLoop) that has already finished
8    RootFinished,
9}
10
11impl core::fmt::Display for Error {
12    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
13        match self {
14            Self::Io(errno) => write!(f, "event loop IO error: {errno}"),
15            Self::RootFinished => f.write_str("the root future has finished"),
16        }
17    }
18}
19
20impl core::error::Error for Error {}