use std::error::Error;
use std::fmt;
use crate::error::InternalError;
#[derive(Debug)]
pub enum NextEventError {
Disconnected,
InternalError(InternalError),
}
impl fmt::Display for NextEventError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
NextEventError::Disconnected => f.write_str("Disconnected"),
NextEventError::InternalError(e) => f.write_str(&e.to_string()),
}
}
}
impl Error for NextEventError {
fn source(&self) -> Option<&(dyn Error + 'static)> {
match self {
NextEventError::Disconnected => None,
NextEventError::InternalError(ref e) => Some(&*e),
}
}
}
#[derive(Debug)]
pub enum WaitForError {
TimeoutError,
NextEventError(NextEventError),
}
impl fmt::Display for WaitForError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
WaitForError::TimeoutError => f.write_str("Timeout"),
WaitForError::NextEventError(e) => f.write_str(&e.to_string()),
}
}
}
impl Error for WaitForError {
fn source(&self) -> Option<&(dyn Error + 'static)> {
match self {
WaitForError::TimeoutError => None,
WaitForError::NextEventError(ref e) => Some(&*e),
}
}
}