Remove clipboard_windows and simplify modules

This commit is contained in:
Héctor Ramón Jiménez 2020-03-12 07:12:02 +01:00
parent 8161059964
commit f697ee10bd
10 changed files with 100 additions and 350 deletions

View file

@ -1,8 +1,8 @@
use xcb::Atom;
use xcb::base::{ ConnError, GenericError };
use std::error::Error as StdError;
use std::fmt;
use std::sync::mpsc::SendError;
use std::error::Error as StdError;
use xcb::base::{ConnError, GenericError};
use xcb::Atom;
#[must_use]
#[derive(Debug)]
@ -10,27 +10,24 @@ pub enum Error {
Set(SendError<Atom>),
XcbConn(ConnError),
XcbGeneric(GenericError),
Lock,
Timeout,
Owner,
UnexpectedType(Atom),
#[doc(hidden)]
__Unknown
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
use self::Error::*;
match self {
Set(e) => write!(f, "XCB - couldn't set atom: {:?}", e),
XcbConn(e) => write!(f, "XCB connection error: {:?}", e),
XcbGeneric(e) => write!(f, "XCB generic error: {:?}", e),
Lock => write!(f, "XCB: Lock is poisoned"),
Timeout => write!(f, "Selection timed out"),
Owner => write!(f, "Failed to set new owner of XCB selection"),
UnexpectedType(target) => write!(f, "Unexpected Reply type: {}", target),
__Unknown => unreachable!()
Error::Set(e) => write!(f, "XCB - couldn't set atom: {:?}", e),
Error::XcbConn(e) => write!(f, "XCB connection error: {:?}", e),
Error::XcbGeneric(e) => write!(f, "XCB generic error: {:?}", e),
Error::Timeout => write!(f, "Selection timed out"),
Error::Owner => {
write!(f, "Failed to set new owner of XCB selection")
}
Error::UnexpectedType(target) => {
write!(f, "Unexpected Reply type: {}", target)
}
}
}
}
@ -42,8 +39,7 @@ impl StdError for Error {
Set(e) => Some(e),
XcbConn(e) => Some(e),
XcbGeneric(e) => Some(e),
Lock | Timeout | Owner | UnexpectedType(_) => None,
__Unknown => unreachable!()
Timeout | Owner | UnexpectedType(_) => None,
}
}
}
@ -55,7 +51,7 @@ macro_rules! define_from {
Error::$item(err)
}
}
}
};
}
define_from!(Set from SendError<Atom>);