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
#![feature(test, try_from)]
extern crate crypto_currency as currency;
extern crate crypto_market as market;
extern crate crypto_market_event as event;
extern crate crypto_market_stream as stream;
extern crate crypto_market_stream_ws as ws;
extern crate crypto_util as util;
#[macro_use]
extern crate error_chain;
extern crate futures;
#[macro_use]
extern crate log;
extern crate serde_json;
extern crate test;
pub mod errors;
mod parse;
mod serialize;
use market::Market;
use stream::Command;
use ws::Message;
use self::errors::Error;
use self::parse::parse_message;
use self::serialize::serialize;
pub struct Protocol;
impl ws::Protocol for Protocol {
type Error = Error;
fn address() -> &'static str {
"wss://api2.poloniex.com:443"
}
fn market() -> Market {
Market::Poloniex
}
fn parse(msg: &str) -> Result<Option<Message>, Self::Error> {
parse_message(msg).map_err(|e| e.into())
}
fn serialize(cmd: Command) -> String {
serialize(cmd)
}
}