[−][src]Struct ws_stream_tungstenite::WsStream
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]
self: Pin<&mut Self>,
cx: &mut Context,
buf: &[u8]
) -> Poll<Result<usize>>
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.
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<()>>
[src]
fn poll_close(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<()>>
[src]
fn poll_write_vectored(
self: Pin<&mut Self>,
cx: &mut Context,
bufs: &[IoSlice]
) -> Poll<Result<usize, Error>>
[src]
self: Pin<&mut Self>,
cx: &mut Context,
bufs: &[IoSlice]
) -> Poll<Result<usize, Error>>
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,
S: Send,
impl<S> Unpin for WsStream<S>
impl<S> Sync for WsStream<S> where
S: Send,
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]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<W> AsyncWriteExt for W where
W: AsyncWrite + ?Sized,
[src]
W: AsyncWrite + ?Sized,
fn flush(&mut self) -> Flush<Self> where
Self: Unpin,
[src]
Self: Unpin,
fn close(&mut self) -> Close<Self> where
Self: Unpin,
[src]
Self: Unpin,
fn write(&'a mut self, buf: &'a [u8]) -> Write<'a, Self> where
Self: Unpin,
[src]
Self: Unpin,
fn write_vectored(
&'a mut self,
bufs: &'a [IoSlice<'a>]
) -> WriteVectored<'a, Self> where
Self: Unpin,
[src]
&'a mut self,
bufs: &'a [IoSlice<'a>]
) -> WriteVectored<'a, Self> where
Self: Unpin,
fn write_all(&'a mut self, buf: &'a [u8]) -> WriteAll<'a, Self> where
Self: Unpin,
[src]
Self: Unpin,
fn compat_write(self) -> Compat<Self> where
Self: Unpin,
[src]
Self: Unpin,
fn into_sink<Item>(self) -> IntoSink<Self, Item> where
Item: AsRef<[u8]>,
[src]
Item: AsRef<[u8]>,
impl<R> AsyncReadExt for R where
R: AsyncRead + ?Sized,
[src]
R: AsyncRead + ?Sized,
fn copy_into<W>(self, writer: &mut W) -> CopyInto<Self, W> where
W: AsyncWrite + Unpin + ?Sized,
[src]
W: AsyncWrite + Unpin + ?Sized,
fn read(&'a mut self, buf: &'a mut [u8]) -> Read<'a, Self> where
Self: Unpin,
[src]
Self: Unpin,
fn read_vectored(
&'a mut self,
bufs: &'a mut [IoSliceMut<'a>]
) -> ReadVectored<'a, Self> where
Self: Unpin,
[src]
&'a mut self,
bufs: &'a mut [IoSliceMut<'a>]
) -> ReadVectored<'a, Self> where
Self: Unpin,
fn read_exact(&'a mut self, buf: &'a mut [u8]) -> ReadExact<'a, Self> where
Self: Unpin,
[src]
Self: Unpin,
fn read_to_end(&'a mut self, buf: &'a mut Vec<u8>) -> ReadToEnd<'a, Self> where
Self: Unpin,
[src]
Self: Unpin,
fn read_to_string(&'a mut self, buf: &'a mut String) -> ReadToString<'a, Self> where
Self: Unpin,
[src]
Self: Unpin,
fn split(self) -> (ReadHalf<Self>, WriteHalf<Self>) where
Self: AsyncWrite,
[src]
Self: AsyncWrite,
fn compat(self) -> Compat<Self> where
Self: Unpin,
[src]
Self: Unpin,
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>,
V: MultiLane<T>,