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