1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#[derive(Debug)]
pub struct NoWaylandLib;
impl std::error::Error for NoWaylandLib {}
#[cfg(not(tarpaulin_include))]
impl std::fmt::Display for NoWaylandLib {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> Result<(), ::std::fmt::Error> {
f.write_str("could not load libwayland-client.so")
}
}
#[derive(Debug)]
pub enum WaylandError {
Io(std::io::Error),
Protocol(crate::protocol::ProtocolError),
}
#[cfg(not(tarpaulin_include))]
impl std::error::Error for WaylandError {
fn cause(&self) -> Option<&dyn std::error::Error> {
match self {
WaylandError::Io(e) => Some(e),
WaylandError::Protocol(e) => Some(e),
}
}
}
#[cfg(not(tarpaulin_include))]
impl std::fmt::Display for WaylandError {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> Result<(), ::std::fmt::Error> {
match self {
WaylandError::Io(e) => write!(f, "Io error: {}", e),
WaylandError::Protocol(e) => std::fmt::Display::fmt(e, f),
}
}
}
#[cfg(not(tarpaulin_include))]
impl Clone for WaylandError {
fn clone(&self) -> WaylandError {
match self {
WaylandError::Protocol(e) => WaylandError::Protocol(e.clone()),
WaylandError::Io(e) => {
if let Some(code) = e.raw_os_error() {
WaylandError::Io(std::io::Error::from_raw_os_error(code))
} else {
WaylandError::Io(std::io::Error::new(e.kind(), ""))
}
}
}
}
}
#[cfg(not(tarpaulin_include))]
impl From<crate::protocol::ProtocolError> for WaylandError {
fn from(err: crate::protocol::ProtocolError) -> WaylandError {
WaylandError::Protocol(err)
}
}
#[cfg(not(tarpaulin_include))]
impl From<std::io::Error> for WaylandError {
fn from(err: std::io::Error) -> WaylandError {
WaylandError::Io(err)
}
}
#[derive(Clone, Debug)]
pub struct InvalidId;
impl std::error::Error for InvalidId {}
#[cfg(not(tarpaulin_include))]
impl std::fmt::Display for InvalidId {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> Result<(), ::std::fmt::Error> {
write!(f, "Invalid ObjectId")
}
}