Skip to main content

drmkit_modeset/
error.rs

1// SPDX-FileCopyrightText: (c) 2026 Joel Winarske
2// SPDX-License-Identifier: MIT
3
4//! Error type for `drmkit-modeset`.
5
6use rustix::io::Errno;
7
8/// Errors from mode selection and page-flip dispatch.
9#[derive(Debug, thiserror::Error)]
10#[non_exhaustive]
11pub enum ModesetError {
12    /// No usable mode. `errc::no_such_device`.
13    #[error("no usable mode")]
14    NoModes,
15
16    /// Nothing to wait on: the dispatcher holds no DRM descriptor and no
17    /// foreign sources. `errc::bad_file_descriptor`.
18    ///
19    /// Surfaced up front rather than blocking forever on an empty epoll.
20    #[error("dispatcher has nothing to wait on")]
21    NothingToWaitOn,
22
23    /// The wait budget elapsed with no events. `errc::timed_out`.
24    ///
25    /// **Never** produced by an interrupted wait — see
26    /// [`PageFlip::dispatch`](crate::PageFlip::dispatch) and invariant 3.
27    #[error("dispatch timed out")]
28    TimedOut,
29
30    /// A descriptor was rejected: negative, or already registered.
31    /// `errc::invalid_argument`.
32    #[error("invalid or duplicate source descriptor")]
33    InvalidSource,
34
35    /// An underlying syscall failed.
36    #[error("modeset operation failed: {0}")]
37    Io(#[from] Errno),
38}
39
40/// Convenience alias.
41pub type Result<T> = std::result::Result<T, ModesetError>;