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
//! Crypto-bank tectonic database client.
#![feature(test, try_trait)]

#[macro_use]
extern crate log;
#[macro_use]
extern crate failure;
#[macro_use]
extern crate bitflags;
#[macro_use]
extern crate serde_derive;
extern crate byteorder;
extern crate rayon;
extern crate serde;

extern crate cxmr_balances;
extern crate cxmr_exchanges;
extern crate cxmr_feeds;
extern crate glob;
#[macro_use]
extern crate err_convert_macro;

mod codec;
mod dirs;
mod meta;

pub mod dtf;
pub mod sync;

pub use self::codec::*;
pub use self::dirs::*;
pub use self::dtf::{create_dtf, read_dtf};
pub use self::meta::*;
pub use self::sync::TectonicClient;

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

    /// Invalid time range.
    #[fail(display = "time range is invalid")]
    InvalidTimeRange,

    /// Invalid input.
    #[fail(display = "input is invalid: {}", _0)]
    InvalidInput(String),

    /// IO error.
    #[fail(display = "IO error: {}", _0)]
    Io(#[cause] std::io::Error),

    /// Currency module error.
    #[fail(display = "currency module error: {}", _0)]
    Currency(#[cause] cxmr_currency::Error),

    /// Exchange module error.
    #[fail(display = "exchange module error: {}", _0)]
    Exchange(#[cause] cxmr_exchanges::Error),

    /// Connection error.
    #[fail(display = "tectonic connection error")]
    ConnectionError,

    /// Database not found.
    #[fail(display = "database not found: {}", _0)]
    DatabaseNotFound(String),

    /// Server error.
    #[fail(display = "server error: {}", _0)]
    ServerError(String),
}

err_converter_no_args!(OptionNone, std::option::NoneError);
err_converter!(Io, std::io::Error);
err_converter!(Exchange, cxmr_exchanges::Error);
err_converter!(Currency, cxmr_currency::Error);

impl From<std::io::ErrorKind> for Error {
    fn from(k: std::io::ErrorKind) -> Error {
        Error::Io(k.into())
    }
}