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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#![feature(test, try_trait, box_syntax)]
#![recursion_limit = "256"]
#[macro_use]
extern crate log;
#[macro_use]
extern crate failure;
extern crate chrono;
extern crate futures;
extern crate hashbrown;
extern crate tokio;
extern crate websocket_lite;
extern crate cxmr_api_clients_errors;
extern crate cxmr_currency;
extern crate cxmr_exchanges;
extern crate cxmr_feeds;
#[macro_use]
extern crate err_convert_macro;
mod connect;
mod protocol;
pub use self::connect::*;
pub use self::protocol::*;
use futures::channel::mpsc::{UnboundedReceiver, UnboundedSender};
pub type EventSender = UnboundedSender<cxmr_feeds::Events>;
pub type EventReceiver = UnboundedReceiver<cxmr_feeds::Events>;
pub type PrivateEventSender = UnboundedSender<Vec<cxmr_feeds::UserEvent>>;
pub type PrivateEventReceiver = UnboundedReceiver<Vec<cxmr_feeds::UserEvent>>;
#[derive(Debug, Fail)]
pub enum Error {
    
    #[fail(display = "option none")]
    OptionNone,
    
    #[fail(display = "channel send error")]
    TrySendError,
    
    #[fail(display = "url parser error: {:?}", _0)]
    Url(#[cause] url::ParseError),
    
    #[fail(display = "websocket error: {:?}", _0)]
    WebSocket(websocket_lite::Error),
    
    #[fail(display = "api client error: {:?}", _0)]
    Client(#[cause] cxmr_api_clients_errors::Error),
    
    #[fail(display = "exchange error: {:?}", _0)]
    Exchange(#[cause] cxmr_exchanges::Error),
    
    #[fail(display = "currency error: {:?}", _0)]
    Currency(#[cause] cxmr_currency::Error),
    
    #[fail(display = "unexpected event kind: {}", _0)]
    UnexpectedEventKind(String),
}
err_converter!(Url, url::ParseError);
err_converter!(WebSocket, websocket_lite::Error);
err_converter!(Client, cxmr_api_clients_errors::Error);
err_converter!(Exchange, cxmr_exchanges::Error);
err_converter!(Currency, cxmr_currency::Error);
err_converter_no_args!(OptionNone, std::option::NoneError);
err_converter_with_into!(Client, std::num::ParseIntError);
err_converter_with_into!(Client, std::num::ParseFloatError);
impl<I> From<futures::channel::mpsc::TrySendError<I>> for Error {
    fn from(_err: futures::channel::mpsc::TrySendError<I>) -> Self {
        Error::TrySendError
    }
}
unsafe impl Send for Error {}
unsafe impl Sync for Error {}