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
//! Crypto-bank exchanges implementation
#![feature(try_trait)]

#[macro_use]
extern crate failure;
#[macro_use]
extern crate log;
extern crate colored;
extern crate futures_locks;
#[macro_use]
extern crate serde_derive;
extern crate hashbrown;
extern crate serde;

extern crate cxmr_api;
extern crate cxmr_balances;
extern crate cxmr_currency;
extern crate cxmr_exchanges;
extern crate cxmr_feeds;
extern crate cxmr_orderbook;
#[macro_use]
extern crate err_convert_macro;
extern crate cxmr_api_clients_errors;

mod account;
mod broker;
mod exchange;
mod market;
mod statistics;

pub use self::account::*;
pub use self::broker::*;
pub use self::exchange::*;
pub use self::market::*;
pub use self::statistics::*;

/// HTTP API Client module error type.
#[derive(Debug, Fail)]
pub enum Error {
    /// Option is `None` error.
    #[fail(display = "option none")]
    OptionNone,

    /// Mutex poison error.
    #[fail(display = "mutex poison error")]
    MutexPoison,

    /// API clients module error.
    #[fail(display = "api client error: {:?}", _0)]
    Client(#[cause] cxmr_api_clients_errors::Error),

    /// Order book module error.
    #[fail(display = "order book error: {:?}", _0)]
    OrderBook(#[cause] cxmr_orderbook::Error),
}

err_converter!(Client, cxmr_api_clients_errors::Error);
err_converter!(OrderBook, cxmr_orderbook::Error);
err_converter_no_args!(OptionNone, std::option::NoneError);

impl<E> From<std::sync::PoisonError<E>> for Error {
    fn from(_: std::sync::PoisonError<E>) -> Error {
        Error::MutexPoison
    }
}