pub struct WebSocketConnection<H: WebSocketHandler> { /* private fields */ }
Expand description

A struct that holds a websocket connection.

Dropping this struct terminates the connection.

Reconnecting

WebSocketConnection automatically reconnects when an TungsteniteError occurs. Note, that during reconnection, it is possible that the WebSocketHandler receives multiple identical messages even though the message was sent only once by the server, or receives only one message even though multiple identical messages were sent by the server, because there could be a time difference in the new connection and the old connection.

You can use the reconnect_state() method to check if the connection is under a reconnection, or manually request a reconnection.

Implementations§

Starts a new WebSocketConnection to the given url using the given handler.

Sends a message to the connection.

Returns a ReconnectState for this connection.

See ReconnectState for more information.

Trait Implementations§

Formats the value using the given formatter. Read more
Executes the destructor for this 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 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