pub struct ConnectionConfig {
pub url: String,
pub channel_capacity: usize,
pub reconnect: ReconnectPolicy,
pub ping_interval: Duration,
}Expand description
Configuration for a WebSocket feed connection.
Fields§
§url: StringWebSocket URL to connect to (e.g. "wss://stream.binance.com:9443/ws").
channel_capacity: usizeCapacity of the downstream channel that receives incoming messages.
reconnect: ReconnectPolicyReconnect policy applied on disconnection.
ping_interval: DurationPing interval to keep the connection alive (default: 20 s).
Implementations§
Source§impl ConnectionConfig
impl ConnectionConfig
Sourcepub fn new(
url: impl Into<String>,
channel_capacity: usize,
) -> Result<Self, StreamError>
pub fn new( url: impl Into<String>, channel_capacity: usize, ) -> Result<Self, StreamError>
Build a connection configuration for url with the given downstream
channel capacity.
§Errors
Returns StreamError::ConfigError if url is empty or
channel_capacity is zero.
Sourcepub fn with_reconnect(self, policy: ReconnectPolicy) -> Self
pub fn with_reconnect(self, policy: ReconnectPolicy) -> Self
Override the default reconnect policy.
Sourcepub fn with_ping_interval(self, interval: Duration) -> Self
pub fn with_ping_interval(self, interval: Duration) -> Self
Override the keepalive ping interval (default: 20 s).
Sourcepub fn with_reconnect_attempts(self, n: u32) -> Result<Self, StreamError>
pub fn with_reconnect_attempts(self, n: u32) -> Result<Self, StreamError>
Shortcut to set only the reconnect attempt limit without replacing the entire reconnect policy.
§Errors
Returns StreamError::ConfigError if n is zero.
Sourcepub fn with_channel_capacity(self, capacity: usize) -> Result<Self, StreamError>
pub fn with_channel_capacity(self, capacity: usize) -> Result<Self, StreamError>
Override the downstream channel capacity.
§Errors
Returns StreamError::ConfigError if capacity is zero.
Trait Implementations§
Source§impl Clone for ConnectionConfig
impl Clone for ConnectionConfig
Source§fn clone(&self) -> ConnectionConfig
fn clone(&self) -> ConnectionConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more