pub struct SocketConfigBuilder<S: State = Empty> { /* private fields */ }Expand description
Use builder syntax to set the inputs and finish with build_inner().
Implementations§
Source§impl<S: State> SocketConfigBuilder<S>
impl<S: State> SocketConfigBuilder<S>
Sourcepub fn url(self, value: String) -> SocketConfigBuilder<SetUrl<S>>where
S::Url: IsUnset,
pub fn url(self, value: String) -> SocketConfigBuilder<SetUrl<S>>where
S::Url: IsUnset,
Required.
The server address as host:port or a URL.
Sourcepub fn mode(self, value: Mode) -> SocketConfigBuilder<SetMode<S>>where
S::Mode: IsUnset,
pub fn mode(self, value: Mode) -> SocketConfigBuilder<SetMode<S>>where
S::Mode: IsUnset,
Required.
The plain or TLS connection mode.
Sourcepub fn suffix(self, value: Vec<u8>) -> SocketConfigBuilder<SetSuffix<S>>where
S::Suffix: IsUnset,
pub fn suffix(self, value: Vec<u8>) -> SocketConfigBuilder<SetSuffix<S>>where
S::Suffix: IsUnset,
Required.
The byte sequence that frames messages in both directions.
Sourcepub fn message_handler(
self,
value: TcpMessageHandler,
) -> SocketConfigBuilder<SetMessageHandler<S>>where
S::MessageHandler: IsUnset,
pub fn message_handler(
self,
value: TcpMessageHandler,
) -> SocketConfigBuilder<SetMessageHandler<S>>where
S::MessageHandler: IsUnset,
Sourcepub fn maybe_message_handler(
self,
value: Option<TcpMessageHandler>,
) -> SocketConfigBuilder<SetMessageHandler<S>>where
S::MessageHandler: IsUnset,
pub fn maybe_message_handler(
self,
value: Option<TcpMessageHandler>,
) -> SocketConfigBuilder<SetMessageHandler<S>>where
S::MessageHandler: IsUnset,
Sourcepub fn heartbeat(
self,
value: SocketHeartbeat,
) -> SocketConfigBuilder<SetHeartbeat<S>>where
S::Heartbeat: IsUnset,
pub fn heartbeat(
self,
value: SocketHeartbeat,
) -> SocketConfigBuilder<SetHeartbeat<S>>where
S::Heartbeat: IsUnset,
Optional (Some / Option setters). Optional application keepalive.
When set, the client sends SocketHeartbeat::payload every
SocketHeartbeat::interval_secs seconds. A raw socket has no Ping frames, so this type
requires a payload; the WebSocket Ping-frame case stays on
crate::websocket::WebSocketConfig::heartbeat_payload.
Each timing field carries the coarsest unit that expresses every legitimate value, and
quantities compared against each other share a unit: the interval and
Self::heartbeat_timeout_secs are bounded below by whole-second cadences, while reconnect
delays and jitter have real sub-second values and stay in milliseconds.
Sourcepub fn maybe_heartbeat(
self,
value: Option<SocketHeartbeat>,
) -> SocketConfigBuilder<SetHeartbeat<S>>where
S::Heartbeat: IsUnset,
pub fn maybe_heartbeat(
self,
value: Option<SocketHeartbeat>,
) -> SocketConfigBuilder<SetHeartbeat<S>>where
S::Heartbeat: IsUnset,
Optional (Some / Option setters). Optional application keepalive.
When set, the client sends SocketHeartbeat::payload every
SocketHeartbeat::interval_secs seconds. A raw socket has no Ping frames, so this type
requires a payload; the WebSocket Ping-frame case stays on
crate::websocket::WebSocketConfig::heartbeat_payload.
Each timing field carries the coarsest unit that expresses every legitimate value, and
quantities compared against each other share a unit: the interval and
Self::heartbeat_timeout_secs are bounded below by whole-second cadences, while reconnect
delays and jitter have real sub-second values and stay in milliseconds.
Sourcepub fn connect_timeout_ms(
self,
value: u64,
) -> SocketConfigBuilder<SetConnectTimeoutMs<S>>where
S::ConnectTimeoutMs: IsUnset,
pub fn connect_timeout_ms(
self,
value: u64,
) -> SocketConfigBuilder<SetConnectTimeoutMs<S>>where
S::ConnectTimeoutMs: IsUnset,
Optional (Some / Option setters). The timeout (milliseconds) for establishing a usable connection. Defaults to 10 seconds.
Bounds the initial connection attempt, each reconnect attempt, and how long a send waits for the client to become active again. Keep it above the reconnect backoff so a send does not give up part-way through a normal reconnect.
Sourcepub fn maybe_connect_timeout_ms(
self,
value: Option<u64>,
) -> SocketConfigBuilder<SetConnectTimeoutMs<S>>where
S::ConnectTimeoutMs: IsUnset,
pub fn maybe_connect_timeout_ms(
self,
value: Option<u64>,
) -> SocketConfigBuilder<SetConnectTimeoutMs<S>>where
S::ConnectTimeoutMs: IsUnset,
Optional (Some / Option setters). The timeout (milliseconds) for establishing a usable connection. Defaults to 10 seconds.
Bounds the initial connection attempt, each reconnect attempt, and how long a send waits for the client to become active again. Keep it above the reconnect backoff so a send does not give up part-way through a normal reconnect.
Sourcepub fn reconnect_delay_initial_ms(
self,
value: u64,
) -> SocketConfigBuilder<SetReconnectDelayInitialMs<S>>where
S::ReconnectDelayInitialMs: IsUnset,
pub fn reconnect_delay_initial_ms(
self,
value: u64,
) -> SocketConfigBuilder<SetReconnectDelayInitialMs<S>>where
S::ReconnectDelayInitialMs: IsUnset,
Sourcepub fn maybe_reconnect_delay_initial_ms(
self,
value: Option<u64>,
) -> SocketConfigBuilder<SetReconnectDelayInitialMs<S>>where
S::ReconnectDelayInitialMs: IsUnset,
pub fn maybe_reconnect_delay_initial_ms(
self,
value: Option<u64>,
) -> SocketConfigBuilder<SetReconnectDelayInitialMs<S>>where
S::ReconnectDelayInitialMs: IsUnset,
Sourcepub fn reconnect_delay_max_ms(
self,
value: u64,
) -> SocketConfigBuilder<SetReconnectDelayMaxMs<S>>where
S::ReconnectDelayMaxMs: IsUnset,
pub fn reconnect_delay_max_ms(
self,
value: u64,
) -> SocketConfigBuilder<SetReconnectDelayMaxMs<S>>where
S::ReconnectDelayMaxMs: IsUnset,
Sourcepub fn maybe_reconnect_delay_max_ms(
self,
value: Option<u64>,
) -> SocketConfigBuilder<SetReconnectDelayMaxMs<S>>where
S::ReconnectDelayMaxMs: IsUnset,
pub fn maybe_reconnect_delay_max_ms(
self,
value: Option<u64>,
) -> SocketConfigBuilder<SetReconnectDelayMaxMs<S>>where
S::ReconnectDelayMaxMs: IsUnset,
Sourcepub fn reconnect_backoff_factor(
self,
value: f64,
) -> SocketConfigBuilder<SetReconnectBackoffFactor<S>>where
S::ReconnectBackoffFactor: IsUnset,
pub fn reconnect_backoff_factor(
self,
value: f64,
) -> SocketConfigBuilder<SetReconnectBackoffFactor<S>>where
S::ReconnectBackoffFactor: IsUnset,
Sourcepub fn maybe_reconnect_backoff_factor(
self,
value: Option<f64>,
) -> SocketConfigBuilder<SetReconnectBackoffFactor<S>>where
S::ReconnectBackoffFactor: IsUnset,
pub fn maybe_reconnect_backoff_factor(
self,
value: Option<f64>,
) -> SocketConfigBuilder<SetReconnectBackoffFactor<S>>where
S::ReconnectBackoffFactor: IsUnset,
Sourcepub fn reconnect_jitter_ms(
self,
value: u64,
) -> SocketConfigBuilder<SetReconnectJitterMs<S>>where
S::ReconnectJitterMs: IsUnset,
pub fn reconnect_jitter_ms(
self,
value: u64,
) -> SocketConfigBuilder<SetReconnectJitterMs<S>>where
S::ReconnectJitterMs: IsUnset,
Sourcepub fn maybe_reconnect_jitter_ms(
self,
value: Option<u64>,
) -> SocketConfigBuilder<SetReconnectJitterMs<S>>where
S::ReconnectJitterMs: IsUnset,
pub fn maybe_reconnect_jitter_ms(
self,
value: Option<u64>,
) -> SocketConfigBuilder<SetReconnectJitterMs<S>>where
S::ReconnectJitterMs: IsUnset,
Sourcepub fn connection_max_retries(
self,
value: u32,
) -> SocketConfigBuilder<SetConnectionMaxRetries<S>>where
S::ConnectionMaxRetries: IsUnset,
pub fn connection_max_retries(
self,
value: u32,
) -> SocketConfigBuilder<SetConnectionMaxRetries<S>>where
S::ConnectionMaxRetries: IsUnset,
Sourcepub fn maybe_connection_max_retries(
self,
value: Option<u32>,
) -> SocketConfigBuilder<SetConnectionMaxRetries<S>>where
S::ConnectionMaxRetries: IsUnset,
pub fn maybe_connection_max_retries(
self,
value: Option<u32>,
) -> SocketConfigBuilder<SetConnectionMaxRetries<S>>where
S::ConnectionMaxRetries: IsUnset,
Sourcepub fn reconnect_max_attempts(
self,
value: u32,
) -> SocketConfigBuilder<SetReconnectMaxAttempts<S>>where
S::ReconnectMaxAttempts: IsUnset,
pub fn reconnect_max_attempts(
self,
value: u32,
) -> SocketConfigBuilder<SetReconnectMaxAttempts<S>>where
S::ReconnectMaxAttempts: IsUnset,
Optional (Some / Option setters). The maximum number of reconnection attempts before closing the client.
None: Unlimited reconnection attempts (default, recommended for production).Some(n): Transitions to CLOSED oncenconsecutive reconnect attempts have either failed or established connections active for less than 10 seconds.
Sourcepub fn maybe_reconnect_max_attempts(
self,
value: Option<u32>,
) -> SocketConfigBuilder<SetReconnectMaxAttempts<S>>where
S::ReconnectMaxAttempts: IsUnset,
pub fn maybe_reconnect_max_attempts(
self,
value: Option<u32>,
) -> SocketConfigBuilder<SetReconnectMaxAttempts<S>>where
S::ReconnectMaxAttempts: IsUnset,
Optional (Some / Option setters). The maximum number of reconnection attempts before closing the client.
None: Unlimited reconnection attempts (default, recommended for production).Some(n): Transitions to CLOSED oncenconsecutive reconnect attempts have either failed or established connections active for less than 10 seconds.
Sourcepub fn heartbeat_timeout_secs(
self,
value: u64,
) -> SocketConfigBuilder<SetHeartbeatTimeoutSecs<S>>where
S::HeartbeatTimeoutSecs: IsUnset,
pub fn heartbeat_timeout_secs(
self,
value: u64,
) -> SocketConfigBuilder<SetHeartbeatTimeoutSecs<S>>where
S::HeartbeatTimeoutSecs: IsUnset,
Optional (Some / Option setters). The dead-peer timeout (seconds) for the read task.
Seconds rather than milliseconds because this is a multiple of the heartbeat interval: it can never sensibly sit below one heartbeat cycle.
When set, the read task stops and triggers reconnection if no bytes at all arrive within
this duration. A raw socket has no control frames, so any inbound byte refreshes it,
including the venue’s reply to a heartbeat. That makes this the byte-level equivalent of
the WebSocket client’s heartbeat_timeout_secs, not of its idle_timeout_ms: there is
no transport-level way to tell keepalive traffic from data here.
None derives three heartbeat intervals when Self::heartbeat is set, and disables
detection otherwise. Some(0) is rejected. Set an explicit value above the heartbeat
interval so a healthy connection cannot trip it.
Sourcepub fn maybe_heartbeat_timeout_secs(
self,
value: Option<u64>,
) -> SocketConfigBuilder<SetHeartbeatTimeoutSecs<S>>where
S::HeartbeatTimeoutSecs: IsUnset,
pub fn maybe_heartbeat_timeout_secs(
self,
value: Option<u64>,
) -> SocketConfigBuilder<SetHeartbeatTimeoutSecs<S>>where
S::HeartbeatTimeoutSecs: IsUnset,
Optional (Some / Option setters). The dead-peer timeout (seconds) for the read task.
Seconds rather than milliseconds because this is a multiple of the heartbeat interval: it can never sensibly sit below one heartbeat cycle.
When set, the read task stops and triggers reconnection if no bytes at all arrive within
this duration. A raw socket has no control frames, so any inbound byte refreshes it,
including the venue’s reply to a heartbeat. That makes this the byte-level equivalent of
the WebSocket client’s heartbeat_timeout_secs, not of its idle_timeout_ms: there is
no transport-level way to tell keepalive traffic from data here.
None derives three heartbeat intervals when Self::heartbeat is set, and disables
detection otherwise. Some(0) is rejected. Set an explicit value above the heartbeat
interval so a healthy connection cannot trip it.
Sourcepub fn writer_capacity(
self,
value: usize,
) -> SocketConfigBuilder<SetWriterCapacity<S>>where
S::WriterCapacity: IsUnset,
pub fn writer_capacity(
self,
value: usize,
) -> SocketConfigBuilder<SetWriterCapacity<S>>where
S::WriterCapacity: IsUnset,
Optional (Some / Option setters). The maximum number of outstanding messages, including queued, in-flight, and replay messages.
Defaults to 1,024. Sends fail immediately when full. Must be positive and no greater
than [tokio::sync::Semaphore::MAX_PERMITS]. This bounds message count, not payload bytes.
Sourcepub fn maybe_writer_capacity(
self,
value: Option<usize>,
) -> SocketConfigBuilder<SetWriterCapacity<S>>where
S::WriterCapacity: IsUnset,
pub fn maybe_writer_capacity(
self,
value: Option<usize>,
) -> SocketConfigBuilder<SetWriterCapacity<S>>where
S::WriterCapacity: IsUnset,
Optional (Some / Option setters). The maximum number of outstanding messages, including queued, in-flight, and replay messages.
Defaults to 1,024. Sends fail immediately when full. Must be positive and no greater
than [tokio::sync::Semaphore::MAX_PERMITS]. This bounds message count, not payload bytes.
Sourcepub fn certs_dir(self, value: String) -> SocketConfigBuilder<SetCertsDir<S>>where
S::CertsDir: IsUnset,
pub fn certs_dir(self, value: String) -> SocketConfigBuilder<SetCertsDir<S>>where
S::CertsDir: IsUnset,
Optional (Some / Option setters). The path to the certificates directory.
Every certificate that parses from any file directly inside the directory, regardless of
file name, becomes a trust anchor for the connection alongside the bundled webpki-roots
set. No CA or self-signature checks are performed. A certificate chain matched to a
private key in the directory is used as the client certificate instead. Write access to
the directory is therefore equivalent to control over which servers the connection
trusts. Restrict its contents to intended trust anchors. Each anchor loaded from it is
logged at INFO with its SHA-256 fingerprint.
Sourcepub fn maybe_certs_dir(
self,
value: Option<String>,
) -> SocketConfigBuilder<SetCertsDir<S>>where
S::CertsDir: IsUnset,
pub fn maybe_certs_dir(
self,
value: Option<String>,
) -> SocketConfigBuilder<SetCertsDir<S>>where
S::CertsDir: IsUnset,
Optional (Some / Option setters). The path to the certificates directory.
Every certificate that parses from any file directly inside the directory, regardless of
file name, becomes a trust anchor for the connection alongside the bundled webpki-roots
set. No CA or self-signature checks are performed. A certificate chain matched to a
private key in the directory is used as the client certificate instead. Write access to
the directory is therefore equivalent to control over which servers the connection
trusts. Restrict its contents to intended trust anchors. Each anchor loaded from it is
logged at INFO with its SHA-256 fingerprint.
Source§impl<S: IsComplete> SocketConfigBuilder<S>
impl<S: IsComplete> SocketConfigBuilder<S>
Sourcepub fn build(self) -> NetworkConfigResult<SocketConfig>
pub fn build(self) -> NetworkConfigResult<SocketConfig>
Validates and builds the SocketConfig.
§Errors
Returns an error if any field fails validation (see SocketConfig::validate).