[][src]Struct tokio_tungstenite::WebSocketStream

pub struct WebSocketStream<S> { /* fields omitted */ }

A wrapper around an underlying raw stream which implements the WebSocket protocol.

A WebSocketStream<S> represents a handshake that has been completed successfully and both the server and the client are ready for receiving and sending data. Message from a WebSocketStream<S> are accessible through the respective Stream and Sink. Check more information about them in futures-rs crate documentation or have a look on the examples and unit tests for this crate.

Implementations

impl<S> WebSocketStream<S>[src]

pub async fn from_raw_socket(
    stream: S,
    role: Role,
    config: Option<WebSocketConfig>
) -> Self where
    S: AsyncRead + AsyncWrite + Unpin
[src]

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

pub async fn from_partially_read(
    stream: S,
    part: Vec<u8>,
    role: Role,
    config: Option<WebSocketConfig>
) -> Self where
    S: AsyncRead + AsyncWrite + Unpin
[src]

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

pub fn get_ref(&self) -> &S where
    S: AsyncRead + AsyncWrite + Unpin
[src]

Returns a shared reference to the inner stream.

pub fn get_mut(&mut self) -> &mut S where
    S: AsyncRead + AsyncWrite + Unpin
[src]

Returns a mutable reference to the inner stream.

pub fn get_config(&self) -> &WebSocketConfig[src]

Returns a reference to the configuration of the tungstenite stream.

pub async fn close(
    &mut self,
    msg: Option<CloseFrame<'_>>
) -> Result<(), WsError> where
    S: AsyncRead + AsyncWrite + Unpin
[src]

Close the underlying web socket

Trait Implementations

impl<S: Debug> Debug for WebSocketStream<S>[src]

impl<T> Sink<Message> for WebSocketStream<T> where
    T: AsyncRead + AsyncWrite + Unpin
[src]

type Error = WsError

The type of value produced by the sink when an error occurs.

impl<T> Stream for WebSocketStream<T> where
    T: AsyncRead + AsyncWrite + Unpin
[src]

type Item = Result<Message, WsError>

Values yielded by the stream.

Auto Trait Implementations

impl<S> !RefUnwindSafe for WebSocketStream<S>[src]

impl<S> Send for WebSocketStream<S> where
    S: Send
[src]

impl<S> Sync for WebSocketStream<S> where
    S: Sync
[src]

impl<S> Unpin for WebSocketStream<S> where
    S: Unpin
[src]

impl<S> !UnwindSafe for WebSocketStream<S>[src]

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, Item> SinkExt<Item> for T where
    T: Sink<Item> + ?Sized
[src]

impl<T> StreamExt for T where
    T: Stream + ?Sized
[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<S, T, E> TryStream for S where
    S: Stream<Item = Result<T, E>> + ?Sized
[src]

type Ok = T

The type of successful values yielded by this future

type Error = E

The type of failures yielded by this future

impl<S> TryStreamExt for S where
    S: TryStream + ?Sized
[src]

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