pub struct ClientConfigBuilder { /* private fields */ }Expand description
Assembles a ClientConfig, checking it once at the end.
The checks that involve more than one value — a reconnection ceiling below
its own first delay, for instance — cannot be made one setter at a time, so
ClientConfigBuilder::build is where all of them happen and where the
typed error comes from.
Implementations§
Source§impl ClientConfigBuilder
impl ClientConfigBuilder
Sourcepub fn with_adapter_set(self, adapter_set: AdapterSet) -> Self
pub fn with_adapter_set(self, adapter_set: AdapterSet) -> Self
Names the Adapter Set that will serve the session.
Left unset, the server uses an Adapter Set named DEFAULT
[docs/spec/03-requests.md §2.1].
Sourcepub fn with_credentials(self, credentials: Credentials) -> Self
pub fn with_credentials(self, credentials: Credentials) -> Self
Supplies the credentials the session is created with.
Defaults to Credentials::anonymous.
Sourcepub const fn with_transport(self, transport: Transport) -> Self
pub const fn with_transport(self, transport: Transport) -> Self
Forces a particular transport.
Defaults to Transport::WebSocket. The two HTTP variants —
Transport::HttpStreaming and Transport::HttpPolling — are also
implemented, for a network path that mangles WebSocket upgrades.
Sourcepub fn with_options(self, options: ConnectionOptions) -> Self
pub fn with_options(self, options: ConnectionOptions) -> Self
Sets the timeouts, limits and reconnection policy.
Sourcepub fn build(self) -> Result<ClientConfig, ConfigError>
pub fn build(self) -> Result<ClientConfig, ConfigError>
Checks everything and produces the configuration.
§Errors
ConfigError::ZeroDurationifopen_timeout, or a keepalive hint or inactivity commitment that was set, is zero, or if the first retry delay is zero. A zeroopen_timeoutwould abandon every attempt before it started; a zero retry delay would reconnect in a hot loop.ConfigError::DurationTooLargeif any duration exceedsMAX_TIMING, or if a value that travels as a whole number of milliseconds does not fit one. Every timing is checked, including the keepalive slack and both retry delays: an overflowed deadline is an expired one, so a duration too large to add to an instant would silently become the opposite of what it says.ConfigError::RetryCeilingBelowInitialif the reconnection ceiling is below the first delay.
A zero keepalive slack is accepted: it means “allow the server not one millisecond past the interval it promised”, which is aggressive but coherent.
§Examples
use std::time::Duration;
use lightstreamer_rs::{
ClientConfig, ConfigError, ConnectionOptions, ServerAddress,
};
let rejected = ClientConfig::builder(ServerAddress::try_new("wss://push.example.com")?)
.with_options(ConnectionOptions::default().with_open_timeout(Duration::ZERO))
.build();
assert!(matches!(rejected, Err(ConfigError::ZeroDuration { field: "open_timeout" })));Trait Implementations§
Source§impl Clone for ClientConfigBuilder
impl Clone for ClientConfigBuilder
Source§fn clone(&self) -> ClientConfigBuilder
fn clone(&self) -> ClientConfigBuilder
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more