Skip to main content

ConnectionConfig

Struct ConnectionConfig 

Source
pub struct ConnectionConfig {
    pub url: String,
    pub auth: AuthRequest,
    pub connect_timeout: Duration,
    pub read_timeout: Duration,
    pub tls: TlsConfig,
    pub message_buffer: usize,
    pub event_buffer: usize,
    pub client_id: Option<String>,
}
Expand description

Configuration for WebSocket connection.

Debug is implemented manually so embedded credentials cannot leak. The auth field is rendered as <redacted> and any query-string parameter on url whose name case-insensitively matches a known secret key (token, key, apikey, api_key, secret, password) has its value replaced with ***.

Fields§

§url: String

WebSocket endpoint URL

§auth: AuthRequest

Authentication credentials

§connect_timeout: Duration

Connection timeout (default: 30 seconds)

§read_timeout: Duration

Read timeout for messages (default: 30 seconds)

§tls: TlsConfig

Optional TLS customization (custom CA / accept invalid certs). Default means “use the OS trust store” — identical to pre-3.0.1 behaviour.

§message_buffer: usize

Capacity of the inbound message channel that backs messages() and message_stream(). Defaults to DEFAULT_MESSAGE_BUFFER. Use ConnectionConfigBuilder::message_buffer to override.

§event_buffer: usize

Capacity of the lifecycle event channel that backs events() and state_events(). Defaults to DEFAULT_EVENT_BUFFER. Use ConnectionConfigBuilder::event_buffer to override.

§client_id: Option<String>

Optional caller-supplied identifier used as a metric label on the metrics feature. Defaults to None. Low-cardinality only — suitable for deployment / instance / service identifiers, never for per-request UUIDs (Prometheus storage explodes on high-cardinality labels). Values longer than CLIENT_ID_MAX_LEN are truncated by the builder.

Implementations§

Source§

impl ConnectionConfig

Source

pub fn new(url: impl Into<String>, auth: AuthRequest) -> ConnectionConfig

Create a new connection configuration

Source

pub fn builder( url: impl Into<String>, auth: AuthRequest, ) -> ConnectionConfigBuilder

Create a builder for fluent configuration

Source

pub fn client_id(&self) -> Option<&str>

Caller-supplied identifier used as a metric label, or None if unset. See ConnectionConfigBuilder::client_id.

Source

pub fn fugle_stock(auth: AuthRequest) -> ConnectionConfig

Create configuration for Fugle stock WebSocket endpoint

§Example
use marketdata_core::websocket::ConnectionConfig;
use marketdata_core::AuthRequest;

let config = ConnectionConfig::fugle_stock(
    AuthRequest::with_api_key("my-api-key")
);
assert_eq!(config.url, "wss://api.fugle.tw/marketdata/v1.0/stock/streaming");
Source

pub fn fugle_futopt(auth: AuthRequest) -> ConnectionConfig

Create configuration for Fugle futures/options WebSocket endpoint

§Example
use marketdata_core::websocket::ConnectionConfig;
use marketdata_core::AuthRequest;

let config = ConnectionConfig::fugle_futopt(
    AuthRequest::with_api_key("my-api-key")
);
assert_eq!(config.url, "wss://api.fugle.tw/marketdata/v1.0/futopt/streaming");

Trait Implementations§

Source§

impl Clone for ConnectionConfig

Source§

fn clone(&self) -> ConnectionConfig

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 ConnectionConfig

Source§

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

Formats the value using the given formatter. 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<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, 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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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