Skip to main content

ClientConfigBuilder

Struct ClientConfigBuilder 

Source
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

Source

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

Source

pub fn with_credentials(self, credentials: Credentials) -> Self

Supplies the credentials the session is created with.

Defaults to Credentials::anonymous.

Source

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.

Source

pub fn with_options(self, options: ConnectionOptions) -> Self

Sets the timeouts, limits and reconnection policy.

Source

pub fn build(self) -> Result<ClientConfig, ConfigError>

Checks everything and produces the configuration.

§Errors
  • ConfigError::ZeroDuration if open_timeout, or a keepalive hint or inactivity commitment that was set, is zero, or if the first retry delay is zero. A zero open_timeout would abandon every attempt before it started; a zero retry delay would reconnect in a hot loop.
  • ConfigError::DurationTooLarge if any duration exceeds MAX_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::RetryCeilingBelowInitial if 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

Source§

fn clone(&self) -> ClientConfigBuilder

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 ClientConfigBuilder

Source§

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

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