blob: 81c69e50907b76b64582b3d60661bee28987732f (
plain)
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
|
use std::fmt::{ self, Display };
#[derive(Debug)]
pub struct Error(String);
pub type Result<T> = std::result::Result<T, Error>;
impl Display for Error {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(formatter, "Error: {}", self.0)
}
}
impl From<xcb::Error> for Error {
fn from(error: xcb::Error) -> Error {
match error {
xcb::Error::Connection(error) => error.into(),
xcb::Error::Protocol(error) => error.into(),
}
}
}
impl From<xcb::ConnError> for Error {
fn from(error: xcb::ConnError) -> Error {
Error(format!("X connection: {}", error))
}
}
impl From<xcb::ProtocolError> for Error {
fn from(error: xcb::ProtocolError) -> Error {
Error(format!("X protocol: {}", error))
}
}
|