use crate::OperationError;
use std::fmt;
#[derive(Debug)]
pub enum TimeoutError {
Elapsed,
Clock(OperationError),
}
impl fmt::Display for TimeoutError {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Elapsed => formatter.write_str("operation timed out"),
Self::Clock(error) => write!(formatter, "timeout clock failed: {error}"),
}
}
}
impl std::error::Error for TimeoutError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match self {
Self::Elapsed => None,
Self::Clock(error) => Some(error),
}
}
}