Enum ws_stream_tungstenite::WsEvent[][src]

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

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.

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.

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.

Pong(Vec<u8>)

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

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

impl Clone for WsEvent[src]

impl Debug for WsEvent[src]

impl<S> Observable<WsEvent> for WsStream<S> where
    S: AsyncRead + AsyncWrite + Send + Unpin
[src]

type Error = WsErr

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

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

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