Skip to main content

wl_data_control_protocol_evt/
errors.rs

1use crate::EpollError;
2use wayland_client::{ConnectError, DispatchError, backend::WaylandError};
3
4/// An error that may occur when establishing connection to Wayland
5#[derive(Debug)]
6pub enum ExtDataControlConnectError {
7    /// failed to connect
8    ConnectError(ConnectError),
9    /// failed to send events
10    DispatchError(DispatchError),
11    /// wayland returned an error
12    WaylandError(WaylandError),
13    /// failed to call any of `epoll*` functions
14    EpollError(EpollError),
15    /// no seat was returned from wayland (something is completely broken)
16    NoSeat,
17    /// `ext-data-control` protocol is not supported by compositor
18    Unsupported,
19}
20
21impl core::fmt::Display for ExtDataControlConnectError {
22    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
23        match self {
24            Self::ConnectError(err) => write!(f, "ConnectError({err})"),
25            Self::DispatchError(err) => write!(f, "DispatchError({err})"),
26            Self::WaylandError(err) => write!(f, "WaylandError({err})"),
27            Self::EpollError(err) => write!(f, "EpollError({err})"),
28            Self::NoSeat => write!(f, "NoSeat"),
29            Self::Unsupported => write!(f, "Unsupported"),
30        }
31    }
32}
33
34impl core::error::Error for ExtDataControlConnectError {}
35
36impl From<ConnectError> for ExtDataControlConnectError {
37    fn from(err: ConnectError) -> Self {
38        Self::ConnectError(err)
39    }
40}
41
42impl From<DispatchError> for ExtDataControlConnectError {
43    fn from(err: DispatchError) -> Self {
44        Self::DispatchError(err)
45    }
46}
47
48impl From<WaylandError> for ExtDataControlConnectError {
49    fn from(err: WaylandError) -> Self {
50        Self::WaylandError(err)
51    }
52}
53
54impl From<EpollError> for ExtDataControlConnectError {
55    fn from(err: EpollError) -> Self {
56        Self::EpollError(err)
57    }
58}
59
60/// An error that may occur during reading from Wayland socket
61#[derive(Debug)]
62pub enum ExtDataControlReadError {
63    /// failed to send events
64    DispatchError(DispatchError),
65    /// wayland returned an error
66    WaylandError(WaylandError),
67    /// failed to acquire a lock on a queue
68    FailedToCreateReadGuard,
69    /// failed to call any of `epoll*` functions
70    EpollError(EpollError),
71}
72
73impl core::fmt::Display for ExtDataControlReadError {
74    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
75        match self {
76            Self::WaylandError(err) => write!(f, "WaylandError({err})"),
77            Self::DispatchError(err) => write!(f, "DispatchError({err})"),
78            Self::FailedToCreateReadGuard => write!(f, "FailedToCreateReadGuard"),
79            Self::EpollError(err) => write!(f, "EpollError({err})"),
80        }
81    }
82}
83
84impl core::error::Error for ExtDataControlReadError {}
85
86impl From<EpollError> for ExtDataControlReadError {
87    fn from(err: EpollError) -> Self {
88        Self::EpollError(err)
89    }
90}
91
92impl From<WaylandError> for ExtDataControlReadError {
93    fn from(err: WaylandError) -> Self {
94        Self::WaylandError(err)
95    }
96}
97
98impl From<DispatchError> for ExtDataControlReadError {
99    fn from(err: DispatchError) -> Self {
100        Self::DispatchError(err)
101    }
102}