1#[derive(Clone, Debug)]
2pub struct Config {
3 pub rest_api_endpoint: String,
4 pub ws_endpoint: String,
5
6 pub futures_rest_api_endpoint: String,
7 pub futures_ws_endpoint: String,
8
9 pub recv_window: u64,
10}
11
12impl Default for Config {
13 fn default() -> Self {
14 Self {
15 rest_api_endpoint: "https://api.binance.com".into(),
16 ws_endpoint: "wss://stream.binance.com/ws".into(),
17
18 futures_rest_api_endpoint: "https://fapi.binance.com".into(),
19 futures_ws_endpoint: "wss://fstream.binance.com/ws".into(),
20
21 recv_window: 5000,
22 }
23 }
24}
25
26impl Config {
27 pub fn testnet() -> Self {
28 Self::default()
29 .set_rest_api_endpoint("https://testnet.binance.vision")
30 .set_ws_endpoint("wss://testnet.binance.vision/ws")
31 .set_futures_rest_api_endpoint("https://testnet.binancefuture.com")
32 .set_futures_ws_endpoint("https://testnet.binancefuture.com/ws")
33 }
34
35 pub fn set_rest_api_endpoint<T: Into<String>>(mut self, rest_api_endpoint: T) -> Self {
36 self.rest_api_endpoint = rest_api_endpoint.into();
37 self
38 }
39
40 pub fn set_ws_endpoint<T: Into<String>>(mut self, ws_endpoint: T) -> Self {
41 self.ws_endpoint = ws_endpoint.into();
42 self
43 }
44 pub fn set_futures_rest_api_endpoint<T: Into<String>>(
45 mut self, futures_rest_api_endpoint: T,
46 ) -> Self {
47 self.futures_rest_api_endpoint = futures_rest_api_endpoint.into();
48 self
49 }
50
51 pub fn set_futures_ws_endpoint<T: Into<String>>(mut self, futures_ws_endpoint: T) -> Self {
52 self.futures_ws_endpoint = futures_ws_endpoint.into();
53 self
54 }
55
56 pub fn set_recv_window(mut self, recv_window: u64) -> Self {
57 self.recv_window = recv_window;
58 self
59 }
60}