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
#[derive(Clone, Debug, PartialEq)]
pub struct Config {
pub rest_api_endpoint: String,
pub ws_endpoint: String,
pub futures_rest_api_endpoint: String,
pub futures_ws_endpoint: String,
pub recv_window: u64,
}
impl Config {
pub fn default() -> Config {
Config {
rest_api_endpoint: "https://api.binance.com".into(),
ws_endpoint: "wss://stream.binance.com:9443".into(),
futures_rest_api_endpoint: "https://fapi.binance.com".into(),
futures_ws_endpoint: "wss://fstream.binance.com:9443".into(),
recv_window: 5000,
}
}
pub fn testnet() -> Config {
Config::default()
.set_rest_api_endpoint("https://testnet.binance.vision")
.set_ws_endpoint("wss://testnet.binance.vision")
.set_futures_rest_api_endpoint("https://testnet.binancefuture.com")
.set_futures_ws_endpoint("wss://testnet.binancefuture.com")
}
pub fn set_rest_api_endpoint<T: Into<String>>(mut self, rest_api_endpoint: T) -> Self {
self.rest_api_endpoint = rest_api_endpoint.into();
self
}
pub fn set_ws_endpoint<T: Into<String>>(mut self, ws_endpoint: T) -> Self {
self.ws_endpoint = ws_endpoint.into();
self
}
pub fn set_futures_rest_api_endpoint<T: Into<String>>(mut self, futures_rest_api_endpoint: T) -> Self {
self.futures_rest_api_endpoint = futures_rest_api_endpoint.into();
self
}
pub fn set_futures_ws_endpoint<T: Into<String>>(mut self, futures_ws_endpoint: T) -> Self {
self.futures_ws_endpoint = futures_ws_endpoint.into();
self
}
pub fn set_recv_window(mut self, recv_window: u64) -> Self {
self.recv_window = recv_window;
self
}
}