#[derive(Debug)]
pub struct NoWaylandLib;
impl std::error::Error for NoWaylandLib {}
impl std::fmt::Display for NoWaylandLib {
#[cfg_attr(coverage, no_coverage)]
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),
}
impl std::error::Error for WaylandError {
#[cfg_attr(coverage, no_coverage)]
fn cause(&self) -> Option<&dyn std::error::Error> {
match self {
Self::Io(e) => Some(e),
Self::Protocol(e) => Some(e),
}
}
}
impl std::fmt::Display for WaylandError {
#[cfg_attr(coverage, no_coverage)]
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> Result<(), ::std::fmt::Error> {
match self {
Self::Io(e) => write!(f, "Io error: {}", e),
Self::Protocol(e) => std::fmt::Display::fmt(e, f),
}
}
}
impl Clone for WaylandError {
#[cfg_attr(coverage, no_coverage)]
fn clone(&self) -> Self {
match self {
Self::Protocol(e) => Self::Protocol(e.clone()),
Self::Io(e) => {
if let Some(code) = e.raw_os_error() {
Self::Io(std::io::Error::from_raw_os_error(code))
} else {
Self::Io(std::io::Error::new(e.kind(), ""))
}
}
}
}
}
impl From<crate::protocol::ProtocolError> for WaylandError {
#[cfg_attr(coverage, no_coverage)]
fn from(err: crate::protocol::ProtocolError) -> Self {
Self::Protocol(err)
}
}
impl From<std::io::Error> for WaylandError {
#[cfg_attr(coverage, no_coverage)]
fn from(err: std::io::Error) -> Self {
Self::Io(err)
}
}
#[derive(Clone, Debug)]
pub struct InvalidId;
impl std::error::Error for InvalidId {}
impl std::fmt::Display for InvalidId {
#[cfg_attr(coverage, no_coverage)]
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> Result<(), ::std::fmt::Error> {
write!(f, "Invalid ObjectId")
}
}