pub struct Config {Show 15 fields
pub url: String,
pub command_queue_size: usize,
pub event_queue_size: usize,
pub max_reconnect_attempts: u32,
pub reconnect_base_delay: Duration,
pub reconnect_max_delay: Duration,
pub close_timeout: Duration,
pub connect_timeout: Duration,
pub ping_interval: Option<Duration>,
pub pong_timeout: Duration,
pub api_key: Option<SensitiveString>,
pub api_secret: Option<SensitiveString>,
pub auth_recv_window: Timestamp,
pub server_clock: ServerClock,
pub request_timeout: Duration,
}Expand description
Configuration of a Stream; start with Config::public, Config::private or Config::new.
Fields§
§url: StringWebSocket server URL
command_queue_size: usizeMaximum number of pending commands (backpressure)
event_queue_size: usizeMaximum number of buffered events (backpressure)
max_reconnect_attempts: u32Maximum number of consecutive reconnect attempts without a successful connection (0 = no reconnect). The counter resets once a connection is established.
reconnect_base_delay: DurationBase delay between reconnect attempts
reconnect_max_delay: DurationMaximum delay cap for exponential back-off
close_timeout: DurationHow long to wait for a clean close handshake
connect_timeout: DurationHow long to wait for the TCP/TLS/WebSocket handshake to complete.
ping_interval: Option<Duration>How often to send a Ping frame to the server.
None disables the heartbeat entirely.
pong_timeout: DurationHow long to wait for a Pong after sending a Ping before treating the
connection as dead and triggering a reconnect.
Ignored when ping_interval is None.
api_key: Option<SensitiveString>API key for private streams. With Config::api_secret set, the
driver authenticates on every (re)connect before subscribing.
api_secret: Option<SensitiveString>API secret for private streams (see Config::api_key).
auth_recv_window: TimestampHow long the auth message (and, for
TradeClient, each order entry request)
stays valid, milliseconds.
server_clock: ServerClockClock used for the auth expiry; share
http::Client::clock to use the offset
measured by sync_time.
request_timeout: DurationHow long TradeClient waits for the reply
to an order entry request.
Implementations§
Source§impl Config
impl Config
Sourcepub fn new(url: impl Into<String>) -> Self
pub fn new(url: impl Into<String>) -> Self
Config for a stream URL, e.g. wss://stream.bybit.com/v5/public/linear, with default settings.
Sourcepub fn public(env: Environment, category: Category) -> Self
pub fn public(env: Environment, category: Category) -> Self
Config for the public stream of category in env.
Sourcepub fn trade(env: Environment) -> Result<Self, Error>
pub fn trade(env: Environment) -> Result<Self, Error>
Config for the order entry stream of env, used by
TradeClient. Fails where Bybit offers no
order entry stream (see Environment::trade_stream_url).
Sourcepub fn private(env: Environment) -> Self
pub fn private(env: Environment) -> Self
Config for the private stream (orders, positions, executions,
wallet) in env.
Sourcepub fn command_queue_size(self, n: usize) -> Self
pub fn command_queue_size(self, n: usize) -> Self
Maximum number of pending commands; further commands wait
(or fail with QueueFull for try_*).
Sourcepub fn event_queue_size(self, n: usize) -> Self
pub fn event_queue_size(self, n: usize) -> Self
Maximum number of buffered events; data events beyond it are dropped
and reported by Event::Lagged.
Sourcepub fn max_reconnect_attempts(self, n: u32) -> Self
pub fn max_reconnect_attempts(self, n: u32) -> Self
Maximum consecutive reconnect attempts without a successful connection; 0 disables reconnecting.
Sourcepub fn reconnect_base_delay(self, d: Duration) -> Self
pub fn reconnect_base_delay(self, d: Duration) -> Self
Delay before the first reconnect attempt; it doubles per attempt.
Sourcepub fn reconnect_max_delay(self, d: Duration) -> Self
pub fn reconnect_max_delay(self, d: Duration) -> Self
Upper bound of the reconnect delay.
Sourcepub fn close_timeout(self, d: Duration) -> Self
pub fn close_timeout(self, d: Duration) -> Self
How long to wait for the close handshake on disconnect.
Sourcepub fn connect_timeout(self, d: Duration) -> Self
pub fn connect_timeout(self, d: Duration) -> Self
Timeout of the TCP/TLS/WebSocket handshake.
Sourcepub fn ping_interval(self, d: Option<Duration>) -> Self
pub fn ping_interval(self, d: Option<Duration>) -> Self
Heartbeat interval; None disables the heartbeat.
Sourcepub fn pong_timeout(self, d: Duration) -> Self
pub fn pong_timeout(self, d: Duration) -> Self
How long to wait for the heartbeat reply before reconnecting.
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 for a private stream: the driver sends auth on every
(re)connect and subscribes only after it succeeded.
Sourcepub fn auth_recv_window(self, recv_window: Timestamp) -> Self
pub fn auth_recv_window(self, recv_window: Timestamp) -> Self
Validity of the auth message, milliseconds.
Sourcepub fn request_timeout(self, d: Duration) -> Self
pub fn request_timeout(self, d: Duration) -> Self
How long TradeClient waits for a reply.
Sourcepub fn server_clock(self, clock: ServerClock) -> Self
pub fn server_clock(self, clock: ServerClock) -> Self
Clock for the auth expiry, e.g. client.clock().