pub struct WebSocket<Stream> { /* private fields */ }
Expand description

WebSocket input-output stream.

This is THE structure you want to create to be able to speak the WebSocket protocol. It may be created by calling connect, accept or client functions.

Implementations

Convert a raw socket into a WebSocket without performing a handshake.

Call this function if you’re using Tungstenite as a part of a web framework or together with an existing one. If you need an initial handshake, use connect() or accept() functions of the crate to construct a websocket.

Convert a raw socket into a WebSocket without performing a handshake.

Call this function if you’re using Tungstenite as a part of a web framework or together with an existing one. If you need an initial handshake, use connect() or accept() functions of the crate to construct a websocket.

Returns a shared reference to the inner stream.

Returns a mutable reference to the inner stream.

Change the configuration.

Read a message from stream, if possible.

This function sends pong and close responses automatically. However, it never blocks on write.

Send a message to stream, if possible.

WebSocket will buffer a configurable number of messages at a time, except to reply to Ping and Close requests. If the WebSocket’s send queue is full, SendQueueFull will be returned along with the passed message. Otherwise, the message is queued and Ok(()) is returned.

Note that only the last pong frame is stored to be sent, and only the most recent pong frame is sent if multiple pong frames are queued.

Close the connection.

This function guarantees that the close frame will be queued. There is no need to call it again.

Flush the pending send queue.

Trait Implementations

Formats the value using the given formatter. 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.

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.