1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
use core::fmt;
use std::{error::Error, future::Future, io};
#[derive(Clone, Copy, Eq, PartialEq, PartialOrd, Ord)]
pub struct TimedOutError {
_private: (),
}
impl fmt::Debug for TimedOutError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("TimeoutError").finish()
}
}
impl TimedOutError {
pub(crate) fn new() -> Self {
Self { _private: () }
}
}
impl Error for TimedOutError {}
impl Into<io::Error> for TimedOutError {
fn into(self) -> io::Error {
io::Error::new(io::ErrorKind::TimedOut, "Future has timed out")
}
}
impl fmt::Display for TimedOutError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
"Future has timed out".fmt(f)
}
}
pub trait IntoDeadline {
type Deadline: Future<Output = ()>;
fn into_deadline(self) -> Self::Deadline;
}