[][src]Struct ws_stream_tungstenite::WsStream

pub struct WsStream<S: AsyncRead01 + AsyncWrite01> { /* fields omitted */ }

Takes a WebSocketStream from tokio-tungstenite and implements futures 0.3 AsyncRead/AsyncWrite. Please look at the documentation of the impls for those traits below for details (rustdoc will collapse them).

Methods

impl<S: AsyncRead01 + AsyncWrite01> WsStream<S>[src]

pub fn new(inner: TTungSocket<S>) -> Self[src]

Create a new WsStream.

Trait Implementations

impl<S: AsyncRead01 + AsyncWrite01> Debug for WsStream<S>[src]

impl<S: AsyncRead01 + AsyncWrite01> AsyncWrite for WsStream<S>[src]

Errors

The following errors can be returned when writing to the stream:

  • io::ErrorKind::NotConnected: This means that the connection is already closed. You should drop it. It is safe to drop the underlying connection.

  • io::ErrorKind::InvalidData: This means that a tungstenite::error::Capacity occurred. This means that you send in a buffer bigger than the maximum message size configured on the underlying websocket connection. If you did not set it manually, the default for tungstenite is 64MB.

  • other std::io::Error's generally mean something went wrong on the underlying transport. Consider these fatal and just drop the connection.

fn poll_write(
    self: Pin<&mut Self>,
    cx: &mut Context,
    buf: &[u8]
) -> Poll<Result<usize>>
[src]

Will always flush the underlying socket. Will always create an entire Websocket message from every write, so call with a sufficiently large buffer if you have performance problems.

impl<S: AsyncRead01 + AsyncWrite01> AsyncRead for WsStream<S>[src]

When None is returned, it means it is safe to drop the underlying connection.

Errors

The following errors can be returned from this method:

  • io::ErrorKind::InvalidData: This means that a protocol error was encountered (eg. the remote did something wrong) Protocol error here means either against the websocket protocol or sending websocket Text messages which don't make sense for AsyncRead/AsyncWrite. When these happen, we start the close handshake for the connection, notifying the remote that they made a protocol violation. You should not drop the connection and keep polling this stream until it returns None. That allows tungstenite to properly handle shutting down the connection. Until the remote confirms the close, we might still receive incoming data and it will be passed on to you. In production code you probably want to stop polling this after a timeout if the remote doesn't acknowledge the close.

  • other std::io::Error's generally mean something went wrong on the underlying transport. Consider these fatal and just drop the connection.

Auto Trait Implementations

impl<S> Send for WsStream<S> where
    S: Send

impl<S> Unpin for WsStream<S>

impl<S> Sync for WsStream<S> where
    S: Send

impl<S> !RefUnwindSafe for WsStream<S>

impl<S> !UnwindSafe for WsStream<S>

Blanket Implementations

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

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

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<T> Borrow<T> for T where
    T: ?Sized
[src]

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

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

impl<W> AsyncWriteExt for W where
    W: AsyncWrite + ?Sized
[src]

impl<R> AsyncReadExt for R where
    R: AsyncRead + ?Sized
[src]

impl<T> Erased for T

impl<T> Same<T> for T

type Output = T

Should always be Self

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