Skip to main content

Config

Struct Config 

Source
#[non_exhaustive]
pub struct Config {
Show 22 fields pub url: String, pub token: Option<String>, pub token_provider: Option<TokenProvider>, pub cookie_name: String, pub topics: Vec<String>, pub format: Format, pub compression: bool, pub max_message_size: usize, pub connect_timeout: Duration, pub ready_timeout: Duration, pub heartbeat: Duration, pub idle_timeout: Duration, pub recovery_timeout: Duration, pub reconnect: Reconnect, pub headers: Vec<(String, String)>, pub send_queue: usize, pub tls: Option<Arc<dyn Any + Send + Sync>>, pub encryption: Option<Encryption>, pub delivery: Option<Delivery>, pub offline: Option<Offline>, pub signing_key: Option<Vec<u8>>, pub server_signing_keys: Vec<String>, /* private fields */
}
Expand description

What a client connects to and how it behaves. The defaults are those of the Python and TypeScript clients. Its Debug print leaves the token, the headers’ values and the signing key out.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§url: String

ws://host:port/wse or wss://....

§token: Option<String>

The JWT, sent in the access_token cookie and as Authorization: Bearer. Not in the browser: it sends the page’s cookies itself, and no header.

§token_provider: Option<TokenProvider>

Asked for the token before each connection attempt (within connect_timeout); takes the place of token. A refused token is then fetched again instead of ending the client, three times at most between two connections the server took.

§cookie_name: String

The cookie the token goes in: the server’s jwt_cookie_name.

§topics: Vec<String>

Topics to subscribe to once connected, and again after every reconnect from where the client left off.

§format: Format

How the server sends this client its messages.

§compression: bool

Let the server compress large messages (zlib, above 1 KiB).

§max_message_size: usize

The largest message taken, also after inflating (16 MiB).

§connect_timeout: Duration

For the socket, TLS and the upgrade (10 s).

§ready_timeout: Duration

For the server to confirm the connection after the upgrade (10 s).

§heartbeat: Duration

Between the client’s heartbeats (15 s).

§idle_timeout: Duration

Silence from the server after which the connection is taken for dead and made again (40 s; the server pings every 25 s).

§recovery_timeout: Duration

How long a topic waits for the server to replay messages it missed before reporting the gap (3 s); zero reports it at once.

§reconnect: Reconnect§headers: Vec<(String, String)>

More headers for the upgrade request (not in the browser, which sends none).

§send_queue: usize

Messages waiting to be sent at most; past it try_send fails and send waits (1024). What a lost connection did not write goes out on the next one, once the server takes it. Sends that wait for their topics (Client::send_requiring) are held besides, as many at most: while that many wait, so does the queue.

§tls: Option<Arc<dyn Any + Send + Sync>>

The TLS configuration for wss://: an Arc of a rustls::ClientConfig of rustls 0.23, which this crate builds on, held as Any so that rustls’s own versions are not this crate’s. By default the Mozilla root certificates on aws-lc-rs. In the browser TLS is the browser’s.

ⓘ
config.tls = Some(std::sync::Arc::new(my_rustls_client_config));
§encryption: Option<Encryption>

End-to-end encryption; none by default.

§delivery: Option<Delivery>

The recover-or-resync delivery: a topic that is not continuous holds its messages until the application brought its state up to date, and recovery starts from what it committed. None: best effort, where the topics’ states and the checkpoint are kept all the same.

§offline: Option<Offline>

The outbox: every message sent, except a live or signed one, waits in it until the server answers for it, and goes again after a reconnect; a server that answers (3.2) takes each once. In memory by default; Offline::in_file keeps it past the application’s end. None: no outbox, and a send with no connection fails with Error::NotConnected.

§signing_key: Option<Vec<u8>>

This client’s ECDSA P-256 private key (PKCS#8, PEM or DER) for Client::send_signed. The server learns its public key from the token’s cnf claim or from its application.

§server_signing_keys: Vec<String>

The server’s signing public keys (base64 of the uncompressed point, from the server’s signing_public_key) that the messages it signs are checked against; one failing the check is dropped. Without them signed messages are delivered unchecked.

Implementations§

Source§

impl Config

Source

pub fn new(url: impl Into<String>) -> Self

Trait Implementations§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Self

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 Config

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Config

§

impl !UnwindSafe for Config

§

impl Forget for Config

§

impl Freeze for Config

§

impl Move for Config

§

impl Send for Config

§

impl Sync for Config

§

impl Unpin for Config

§

impl UnsafeUnpin for Config

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> MaybeSend for T
where T: Send,

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

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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