Enum ws_stream_tungstenite::WsEvent[][src]

pub enum WsEvent {
    Error(Arc<WsErr>),
    CloseFrame(Option<CloseFrame<'static>>),
    Ping(Vec<u8>),
    Pong(Vec<u8>),
    Closed,
}
Expand description

Events that can happen on the websocket. These are returned through the stream you can obtain from WsStream::observe. These include close, ping and pong events which can not be returned through AsyncRead/AsyncWrite, and non-fatal errors.

Variants

Error(Arc<WsErr>)

Non fatal error that happened on the websocket. Non-fatal here doesn’t mean the websocket is still usable, but at least is still usable enough to initiate a close handshake. If we bubble up errors through AsyncRead/AsyncWrite, codecs will always return None on subsequent polls, which would prevent from driving the close handshake to completion. Hence they are returned out of band.

Tuple Fields of Error

0: Arc<WsErr>
CloseFrame(Option<CloseFrame<'static>>)

We received a close frame from the remote. Just keep polling the stream. The close handshake will be completed for you. Once the stream returns None, you can drop the WsStream. This is mainly useful in order to recover the close code and reason for debugging purposes.

Tuple Fields of CloseFrame

0: Option<CloseFrame<'static>>
Ping(Vec<u8>)

The remote sent a Ping message. It will automatically be answered as long as you keep polling the AsyncRead. This is returned as an event in case you want to analyze the payload, since only bytes from Binary websocket messages are passed through the AsyncRead.

Tuple Fields of Ping

0: Vec<u8>
Pong(Vec<u8>)

The remote send us a Pong. Since we never send Pings, this is a unidirectional heartbeat.

Tuple Fields of Pong

0: Vec<u8>
Closed

The connection is closed. Polling WsStream will return None on read and io::ErrorKind::NotConnected on write soon. It’s provided here for convenience so the task listening to these events know that the connection closed. You should not see any events after this one, so you can drop the Events stream.

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

The error type that is returned if observing is not possible. Read more

Add an observer to the observable. Options allow chosing the channel type and to filter events with a predicate. 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

Performs the conversion.

Performs the conversion.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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.