pub struct Config {
pub base_url: String,
pub api_key: Option<SensitiveString>,
pub api_secret: Option<SensitiveString>,
pub recv_window: Timestamp,
pub referer: Option<String>,
pub rate_limiter: Option<RateLimiterConfig>,
pub timeout: Option<Duration>,
pub connect_timeout: Option<Duration>,
pub proxy: Option<String>,
pub resync_time_on_timestamp_error: bool,
}Expand description
Configuration of a Client; start with Config::new or Config::for_env.
Fields§
§base_url: StringREST base URL, e.g. https://api.bybit.com.
api_key: Option<SensitiveString>API key for private endpoints (see Config::credentials).
api_secret: Option<SensitiveString>API secret for private endpoints (see Config::credentials).
recv_window: TimestampMilliseconds.
referer: Option<String>HTTP the header for broker users only.
rate_limiter: Option<RateLimiterConfig>Optional rate limiter. When Some, every request is pre-flight-checked
against a local token bucket and the last server-reported limit status.
Set to None to disable rate limiting entirely.
timeout: Option<Duration>Total timeout of one request (connect + send + receive).
None disables it, which is not recommended: a hung request would
then wait forever.
connect_timeout: Option<Duration>Timeout of establishing a connection. None disables it.
proxy: Option<String>HTTP(S) proxy for REST requests, e.g. http://127.0.0.1:8080. None
uses the system proxy settings (HTTP(S)_PROXY). WebSocket streams do
not use it.
resync_time_on_timestamp_error: boolWhen Bybit rejects a signed request’s timestamp (retCode 10002),
call Client::sync_time and send the request once more, signed with
the server time. Safe: the rejected request was not executed.
Enabled by default.
Implementations§
Source§impl Config
impl Config
Sourcepub fn new(base_url: impl Into<String>) -> Self
pub fn new(base_url: impl Into<String>) -> Self
Config for public endpoints with default timeouts and no rate limiter.
Sourcepub fn for_env(env: Environment) -> Self
pub fn for_env(env: Environment) -> Self
Config for the REST API of env, e.g. Config::for_env(Environment::Demo).
Sourcepub fn credentials(
self,
api_key: impl Into<SensitiveString>,
api_secret: impl Into<SensitiveString>,
) -> Self
pub fn credentials( self, api_key: impl Into<SensitiveString>, api_secret: impl Into<SensitiveString>, ) -> Self
Credentials required by private endpoints.
Sourcepub fn recv_window(self, recv_window: Timestamp) -> Self
pub fn recv_window(self, recv_window: Timestamp) -> Self
Milliseconds.
Sourcepub fn rate_limiter(self, rate_limiter: RateLimiterConfig) -> Self
pub fn rate_limiter(self, rate_limiter: RateLimiterConfig) -> Self
Enable the local rate limiter.
Sourcepub fn timeout(self, timeout: Option<Duration>) -> Self
pub fn timeout(self, timeout: Option<Duration>) -> Self
Total timeout of one request; None disables it.
Sourcepub fn connect_timeout(self, connect_timeout: Option<Duration>) -> Self
pub fn connect_timeout(self, connect_timeout: Option<Duration>) -> Self
Timeout of establishing a connection; None disables it.
Sourcepub fn proxy(self, url: impl Into<String>) -> Self
pub fn proxy(self, url: impl Into<String>) -> Self
HTTP(S) proxy for REST requests, e.g. http://127.0.0.1:8080.
Sourcepub fn resync_time_on_timestamp_error(self, enabled: bool) -> Self
pub fn resync_time_on_timestamp_error(self, enabled: bool) -> Self
Re-synchronize the clock and retry once when Bybit rejects a
request timestamp (retCode 10002). Enabled by default.