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
#[derive(Clone, Debug)]
pub struct Config<'a> {
    pub rest_api_endpoint: &'a str,
    pub ws_endpoint: &'a str,
    pub recv_window: u16,
}

impl <'a> Config<'_> {
    pub const DEFAULT_REST_API_ENDPOINT: &'a str = "https://api.bybit.com";
    pub const DEFAULT_WS_ENDPOINT: &'a str = "wss://stream.bybit.com/v5";

    pub const fn default() -> Self {
        Self {
            rest_api_endpoint: Self::DEFAULT_REST_API_ENDPOINT,
            ws_endpoint: Self::DEFAULT_WS_ENDPOINT,
            recv_window: 5000,
        }
    }

    pub const fn testnet() -> Self {
        Self {
            rest_api_endpoint: "https://api-testnet.bybit.com",
            ws_endpoint: "wss://stream-testnet.bybit.com/v5",
            recv_window: 5000,
        }
    }

    pub const fn set_recv_window(self, recv_window: u16) -> Self {
        Self {
            recv_window,
            ..self
        }
    }
}