use std::fmt;
use std::time::Duration;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct ClockError {
behind: Duration,
}
impl ClockError {
pub(crate) fn new(behind: Duration) -> Self {
Self { behind }
}
#[must_use]
pub fn behind(&self) -> Duration {
self.behind
}
}
impl fmt::Display for ClockError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "system clock is {:?} before the Unix epoch", self.behind)
}
}
impl std::error::Error for ClockError {}
#[cfg(test)]
#[path = "error.test.rs"]
mod tests;