drmkit_dumb/error.rs
1// SPDX-FileCopyrightText: (c) 2026 Joel Winarske
2// SPDX-License-Identifier: MIT
3
4//! Error type for `drmkit-dumb`.
5
6use rustix::io::Errno;
7
8/// Errors from dumb-buffer allocation and framebuffer registration.
9#[derive(Debug, thiserror::Error)]
10#[non_exhaustive]
11pub enum DumbError {
12 /// Zero or out-of-range dimensions, a zero format or bpp, or a `FourCC`
13 /// the `drm` crate does not recognize.
14 /// `errc::invalid_argument`.
15 #[error("invalid dumb buffer configuration: {reason}")]
16 InvalidConfig {
17 /// What was wrong.
18 reason: &'static str,
19 },
20
21 /// The `FourCC` is not one [`Buffer::create_planar`](crate::Buffer::create_planar)
22 /// recognizes. `errc::not_supported`.
23 ///
24 /// Callers can fall back to [`Buffer::create`](crate::Buffer::create) for
25 /// single-plane formats.
26 #[error("format {fourcc:#010x} is not a supported semi-planar layout")]
27 UnsupportedFormat {
28 /// The requested `FourCC`.
29 fourcc: u32,
30 },
31
32 /// A size computation would not fit the kernel's 32-bit field.
33 /// `errc::value_too_large`.
34 #[error("dumb buffer geometry overflows a 32-bit kernel field: {what}")]
35 TooLarge {
36 /// Which computation overflowed.
37 what: &'static str,
38 },
39
40 /// An ioctl or mmap failed.
41 #[error("dumb buffer operation failed: {0}")]
42 Io(#[from] Errno),
43}
44
45/// Convenience alias.
46pub type Result<T> = std::result::Result<T, DumbError>;