1use std::{fmt, io};
12use tokio_executor::SpawnError;
13
14pub type Result<T> = std::result::Result<T, Error>;
15
16#[derive(Debug)]
17pub enum Error {
18 Io(io::Error),
19 Exec(SpawnError),
20 NoCapacity,
21 TimerError,
22
23 #[doc(hidden)]
24 __Nonexhaustive
25}
26
27impl fmt::Display for Error {
28 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
29 match self {
30 Error::Io(e) => write!(f, "i/o error: {}", e),
31 Error::Exec(e) => write!(f, "spawn error: {}", e),
32 Error::NoCapacity => f.write_str("no capacity left"),
33 Error::TimerError => f.write_str("error executing background timer"),
34 Error::__Nonexhaustive => f.write_str("__Nonexhaustive")
35 }
36 }
37}
38
39impl std::error::Error for Error {
40 fn cause(&self) -> Option<&dyn std::error::Error> {
41 match self {
42 Error::Io(e) => Some(e),
43 Error::Exec(e) => Some(e),
44 _ => None
45 }
46 }
47}
48
49
50impl From<io::Error> for Error {
51 fn from(e: io::Error) -> Self {
52 Error::Io(e)
53 }
54}
55
56impl From<SpawnError> for Error {
57 fn from(e: SpawnError) -> Self {
58 Error::Exec(e)
59 }
60}