Skip to main content

ConnectionOptions

Struct ConnectionOptions 

Source
pub struct ConnectionOptions { /* private fields */ }
Expand description

Timeouts, buffer sizes and the reconnection policy for one client.

Every field has a default that works against a normally configured server; change only what you have a reason to change. See the module documentation for why these are checked when the ClientConfig is built rather than one at a time.

§Examples

use std::time::Duration;
use lightstreamer_rs::ConnectionOptions;

let options = ConnectionOptions::default()
    .with_open_timeout(Duration::from_secs(5))
    .with_send_sync(false);
assert_eq!(options.open_timeout(), Duration::from_secs(5));

Implementations§

Source§

impl ConnectionOptions

Source

pub const fn with_open_timeout(self, timeout: Duration) -> Self

How long a session-opening request may go unanswered before the attempt is abandoned and retried.

This is a limit of this crate: the protocol defines none, and without one a server that accepts a connection and then says nothing would wedge the client forever. Default: 10 s.

Source

pub const fn with_keepalive_slack(self, slack: Duration) -> Self

Extra grace beyond the server’s own keepalive interval before a silent stream is treated as dead and recovered.

The server promises to send something — a keepalive probe if nothing else — at least this often, and tells the client the interval when the session binds [docs/spec/02-session-lifecycle.md §8.1]. This value is added on top of that negotiated interval to absorb one late probe. Default: 3 s.

The negotiated interval always wins over ConnectionOptions::with_keepalive_hint; this slack is the only part of the liveness budget the caller controls outright.

Source

pub const fn with_keepalive_hint(self, interval: Option<Duration>) -> Self

Asks the server for a particular keepalive interval.

A hint, not a setting: the server clamps it to its own configured minimum and maximum and reports the interval it actually adopted, which is what this client then enforces [docs/spec/02-session-lifecycle.md §8.1]. Leave it unset to let the server choose, which is the default.

Source

pub const fn with_inactivity_commitment( self, interval: Option<Duration>, ) -> Self

Commits to sending the server something at least this often.

If the server hears nothing from the client for longer than this it may conclude the client is stuck and act on it [docs/spec/03-requests.md §2.1]. Setting it makes this crate send a heartbeat whenever nothing else has been sent, at half the committed interval — half being this crate’s choice, so that one lost heartbeat does not break the commitment.

Unset by default: without a commitment there is nothing to keep, and the server applies no such check.

Source

pub const fn with_send_sync(self, enabled: bool) -> Self

Whether to let the server send its periodic clock-synchronisation notifications.

They carry the seconds elapsed on the server since the session began, which lets a client detect that its own machine has been suspended [docs/spec/03-requests.md §2.1]. This crate surfaces them on the session event stream and does not act on them. Default: enabled.

Source

pub const fn with_content_length(self, bytes: Option<NonZeroU64>) -> Self

Asks the server to end each stream connection after this many bytes, forcing a clean rebind.

Chiefly a defence against intermediaries that buffer an endless response; the server raises a value it considers too low [docs/spec/03-requests.md §2.1]. Leave it unset to let the server choose, which is the default. A rebind triggered this way preserves the session and every subscription.

Source

pub const fn with_retry(self, retry: RetryPolicy) -> Self

Sets the reconnection policy.

Source

pub const fn with_session_event_capacity(self, capacity: NonZeroUsize) -> Self

Capacity of the client’s session event stream.

The stream is bounded and never drops: see SessionEvents for what that means for a consumer that falls behind. Default: 256 events.

Source

pub const fn with_update_capacity(self, capacity: NonZeroUsize) -> Self

Capacity of each subscription’s update stream.

Bounded, and never drops: see Updates. Default: 1024 events per subscription.

Source

pub const fn open_timeout(&self) -> Duration

How long a session-opening request may go unanswered.

Source

pub const fn keepalive_slack(&self) -> Duration

Grace beyond the negotiated keepalive interval.

Source

pub const fn keepalive_hint(&self) -> Option<Duration>

The keepalive interval asked of the server, if any.

Source

pub const fn inactivity_commitment(&self) -> Option<Duration>

The inactivity commitment made to the server, if any.

Source

pub const fn send_sync(&self) -> bool

Whether clock-synchronisation notifications are enabled.

Source

pub const fn content_length(&self) -> Option<NonZeroU64>

The requested stream-connection byte budget, if any.

Source

pub const fn retry(&self) -> RetryPolicy

The reconnection policy.

Source

pub const fn session_event_capacity(&self) -> NonZeroUsize

Capacity of the session event stream.

Source

pub const fn update_capacity(&self) -> NonZeroUsize

Capacity of each subscription’s update stream.

Trait Implementations§

Source§

impl Clone for ConnectionOptions

Source§

fn clone(&self) -> ConnectionOptions

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 ConnectionOptions

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for ConnectionOptions

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for ConnectionOptions

Source§

impl PartialEq for ConnectionOptions

Source§

fn eq(&self, other: &ConnectionOptions) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ConnectionOptions

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