Skip to main content

Config

Struct Config 

Source
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: String

WebSocket server URL

§command_queue_size: usize

Maximum number of pending commands (backpressure)

§event_queue_size: usize

Maximum number of buffered events (backpressure)

§max_reconnect_attempts: u32

Maximum number of consecutive reconnect attempts without a successful connection (0 = no reconnect). The counter resets once a connection is established.

§reconnect_base_delay: Duration

Base delay between reconnect attempts

§reconnect_max_delay: Duration

Maximum delay cap for exponential back-off

§close_timeout: Duration

How long to wait for a clean close handshake

§connect_timeout: Duration

How 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: Duration

How 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: Timestamp

How long the auth message (and, for TradeClient, each order entry request) stays valid, milliseconds.

§server_clock: ServerClock

Clock used for the auth expiry; share http::Client::clock to use the offset measured by sync_time.

§request_timeout: Duration

How long TradeClient waits for the reply to an order entry request.

Implementations§

Source§

impl Config

Source

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.

Source

pub fn public(env: Environment, category: Category) -> Self

Config for the public stream of category in env.

Source

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).

Source

pub fn private(env: Environment) -> Self

Config for the private stream (orders, positions, executions, wallet) in env.

Source

pub fn command_queue_size(self, n: usize) -> Self

Maximum number of pending commands; further commands wait (or fail with QueueFull for try_*).

Source

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.

Source

pub fn max_reconnect_attempts(self, n: u32) -> Self

Maximum consecutive reconnect attempts without a successful connection; 0 disables reconnecting.

Source

pub fn reconnect_base_delay(self, d: Duration) -> Self

Delay before the first reconnect attempt; it doubles per attempt.

Source

pub fn reconnect_max_delay(self, d: Duration) -> Self

Upper bound of the reconnect delay.

Source

pub fn close_timeout(self, d: Duration) -> Self

How long to wait for the close handshake on disconnect.

Source

pub fn connect_timeout(self, d: Duration) -> Self

Timeout of the TCP/TLS/WebSocket handshake.

Source

pub fn ping_interval(self, d: Option<Duration>) -> Self

Heartbeat interval; None disables the heartbeat.

Source

pub fn pong_timeout(self, d: Duration) -> Self

How long to wait for the heartbeat reply before reconnecting.

Source

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.

Source

pub fn auth_recv_window(self, recv_window: Timestamp) -> Self

Validity of the auth message, milliseconds.

Source

pub fn request_timeout(self, d: Duration) -> Self

How long TradeClient waits for a reply.

Source

pub fn server_clock(self, clock: ServerClock) -> Self

Clock for the auth expiry, e.g. client.clock().

Trait Implementations§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Config

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Config

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more