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
impl ConnectionOptions
Sourcepub const fn with_open_timeout(self, timeout: Duration) -> Self
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.
Sourcepub const fn with_keepalive_slack(self, slack: Duration) -> Self
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.
Sourcepub const fn with_keepalive_hint(self, interval: Option<Duration>) -> Self
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.
Sourcepub const fn with_inactivity_commitment(
self,
interval: Option<Duration>,
) -> Self
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.
Sourcepub const fn with_send_sync(self, enabled: bool) -> Self
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.
Sourcepub const fn with_content_length(self, bytes: Option<NonZeroU64>) -> Self
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.
Sourcepub const fn with_retry(self, retry: RetryPolicy) -> Self
pub const fn with_retry(self, retry: RetryPolicy) -> Self
Sets the reconnection policy.
Sourcepub const fn with_session_event_capacity(self, capacity: NonZeroUsize) -> Self
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.
Sourcepub const fn with_update_capacity(self, capacity: NonZeroUsize) -> Self
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.
Sourcepub const fn open_timeout(&self) -> Duration
pub const fn open_timeout(&self) -> Duration
How long a session-opening request may go unanswered.
Sourcepub const fn keepalive_slack(&self) -> Duration
pub const fn keepalive_slack(&self) -> Duration
Grace beyond the negotiated keepalive interval.
Sourcepub const fn keepalive_hint(&self) -> Option<Duration>
pub const fn keepalive_hint(&self) -> Option<Duration>
The keepalive interval asked of the server, if any.
Sourcepub const fn inactivity_commitment(&self) -> Option<Duration>
pub const fn inactivity_commitment(&self) -> Option<Duration>
The inactivity commitment made to the server, if any.
Sourcepub const fn content_length(&self) -> Option<NonZeroU64>
pub const fn content_length(&self) -> Option<NonZeroU64>
The requested stream-connection byte budget, if any.
Sourcepub const fn retry(&self) -> RetryPolicy
pub const fn retry(&self) -> RetryPolicy
The reconnection policy.
Sourcepub const fn session_event_capacity(&self) -> NonZeroUsize
pub const fn session_event_capacity(&self) -> NonZeroUsize
Capacity of the session event stream.
Sourcepub const fn update_capacity(&self) -> NonZeroUsize
pub const fn update_capacity(&self) -> NonZeroUsize
Capacity of each subscription’s update stream.
Trait Implementations§
Source§impl Clone for ConnectionOptions
impl Clone for ConnectionOptions
Source§fn clone(&self) -> ConnectionOptions
fn clone(&self) -> ConnectionOptions
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more