bybit/
config.rs

1#[derive(Clone, Debug)]
2pub struct Config {
3    pub rest_api_endpoint: &'static str,
4    pub ws_endpoint: &'static str,
5    pub recv_window: u16,
6}
7
8impl Config {
9    pub const DEFAULT_REST_API_ENDPOINT: &'static str = "https://api.bybit.com";
10    pub const DEFAULT_WS_ENDPOINT: &'static str = "wss://stream.bybit.com/v5";
11
12    pub const fn default() -> Self {
13        Self {
14            rest_api_endpoint: Self::DEFAULT_REST_API_ENDPOINT,
15            ws_endpoint: Self::DEFAULT_WS_ENDPOINT,
16            recv_window: 5000,
17        }
18    }
19
20    pub const fn testnet() -> Self {
21        Self {
22            rest_api_endpoint: "https://api-testnet.bybit.com",
23            ws_endpoint: "wss://stream-testnet.bybit.com/v5",
24            recv_window: 5000,
25        }
26    }
27
28    pub const fn set_recv_window(self, recv_window: u16) -> Self {
29        Self {
30            recv_window,
31            ..self
32        }
33    }
34}