1use std::io::{Error as IoError, ErrorKind as IoErrorKind};
2
3use async_std::future::TimeoutError;
4use dsf_core::error::Error as DsfError;
5
6use futures_codec::JsonCodecError as CodecError;
7
8#[derive(Debug)]
9pub enum Error {
10 Io(IoErrorKind),
11 Codec(CodecError),
12 Remote(DsfError),
13 None(()),
14 UnrecognizedResult,
15 NoServiceFound,
16 Unknown,
17 Timeout,
18 Socket,
19}
20
21impl From<IoError> for Error {
22 fn from(e: IoError) -> Self {
23 Error::Io(e.kind())
24 }
25}
26
27impl From<CodecError> for Error {
28 fn from(e: CodecError) -> Self {
29 Error::Codec(e)
30 }
31}
32
33impl From<DsfError> for Error {
34 fn from(e: DsfError) -> Self {
35 Error::Remote(e)
36 }
37}
38
39impl From<TimeoutError> for Error {
40 fn from(_e: TimeoutError) -> Self {
41 Error::Timeout
42 }
43}
44
45impl From<()> for Error {
46 fn from(e: ()) -> Self {
47 Error::None(e)
48 }
49}