#[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, pub message_timeout: 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

§message_timeout: Duration

A reconnection will be triggered if no messages are received within this amount of time. Defaults to Duration::ZERO, which means no timeout will be applied.

Implementations§

source§

impl WebSocketConfig

source

pub fn new() -> Self

Constructs a new WebSocketConfig with its fields set to default.

Trait Implementations§

source§

impl Clone for WebSocketConfig

source§

fn clone(&self) -> WebSocketConfig

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for WebSocketConfig

source§

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

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

impl Default for WebSocketConfig

source§

fn default() -> Self

Returns the “default value” for a type. 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> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

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

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

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

§

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

§

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more