#[non_exhaustive]
pub struct WebSocketConfig { pub connect_cooldown: Duration, pub refresh_after: Duration, pub url_prefix: String, pub ignore_duplicate_during_reconnection: bool, pub reconnection_wait: Duration, }
Expand description

Configuration for WebSocketHandler.

Should be returned by WebSocketHandler::websocket_config().

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.
§connect_cooldown: Duration

Duration that should elapse between each attempt to start a new connection.

This matters because the WebSocketConnection reconnects on error. If the error continues to happen, it could spam the server if connect_cooldown is too short. Defaults to 3000ms.

§refresh_after: Duration

The WebSocketConnection will automatically reconnect when refresh_after has elapsed since the last connection started. If you don’t want this feature, set it to Duration::ZERO. Defaults to Duration::ZERO.

§url_prefix: String

Prefix which will be used for connections that started using this WebSocketConfig. Defaults to "".

Example usage: "wss://example.com"

§ignore_duplicate_during_reconnection: bool

During reconnection, WebSocketHandler might receive two identical messages even though the server sent only one message. By setting this to true, WebSocketConnection will not send duplicate messages to the WebSocketHandler. You should set this option to true when messages contain some sort of ID and are distinguishable.

Note, that WebSocketConnection will not check duplicate messages when it is not under reconnection even this option is set to true.

§reconnection_wait: Duration

When ignore_duplicate_during_reconnection is set to true, WebSocketConnection will wait for a certain amount of time to make sure no message is lost. Defaults to 300ms

Implementations§

Constructs a new WebSocketConfig with its fields set to default.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more