nuclei/time/error.rs
1//! The error of a timeout.
2
3use std::fmt;
4use std::io;
5
6/// A [`timeout`](super::timeout()) ran out before its future completed.
7#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
8pub struct Elapsed(());
9
10impl Elapsed {
11 pub(super) const fn new() -> Self {
12 Self(())
13 }
14}
15
16impl fmt::Display for Elapsed {
17 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
18 f.write_str("deadline has elapsed")
19 }
20}
21
22impl std::error::Error for Elapsed {}
23
24impl From<Elapsed> for io::Error {
25 fn from(_: Elapsed) -> Self {
26 io::ErrorKind::TimedOut.into()
27 }
28}