timeout_iterator/
error.rs

1use std::fmt;
2use std::fmt::{Debug, Formatter, Result as FmtResult};
3
4#[derive(Debug)]
5pub enum Error {
6    #[cfg(feature = "sync")]
7    ErrorSpawningThread(std::io::Error),
8    TimedOut,
9    Disconnected,
10}
11
12impl std::error::Error for Error {}
13impl fmt::Display for Error {
14    fn fmt(&self, f: &mut Formatter) -> FmtResult {
15        write!(
16            f,
17            "TimeoutIteratorError:: {}",
18            match self {
19                Self::TimedOut =>
20                    "Timed out waiting on the underlying iterator for the next item".to_owned(),
21                Self::Disconnected => "Underlying iterator closed/disconnected".to_owned(),
22
23                #[cfg(feature = "sync")]
24                Self::ErrorSpawningThread(e) => format!(
25                    "Error when spawing a thread for sinking events. Inner io::Error: {}",
26                    e
27                ),
28            }
29        )
30    }
31}
32
33#[cfg(feature = "sync")]
34impl From<std::io::Error> for Error {
35    fn from(err: std::io::Error) -> Self {
36        Self::ErrorSpawningThread(err)
37    }
38}