Struct WebSocket

pub struct WebSocket { /* private fields */ }

A stream of WebSocket messages.

See the module level documentation for more details.

Implementations

impl WebSocket

async fn recv(&mut self) -> Option<Result<Message, Error>>

Receive another message.

Returns None if the stream has closed.

async fn send(&mut self, msg: Message) -> Result<(), Error>

Send a message.

fn protocol(&self) -> Option<&HeaderValue>

Return the selected WebSocket subprotocol, if one has been chosen.

Trait Implementations

impl Debug for WebSocket

fn fmt(&self, f: &mut Formatter<'_>) -> Result

impl FusedStream for WebSocket

fn is_terminated(&self) -> bool

Returns true if the websocket has been terminated.

impl Sink<Message> for WebSocket

type Error = Error;
fn poll_ready(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>>
fn start_send(self: Pin<&mut Self>, item: Message) -> Result<(), Self::Error>
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>>
fn poll_close(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>>

impl Stream for WebSocket

type Item = Result<Message, Error>;
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>>

Auto Trait Implementations

impl !Freeze for WebSocket

impl !RefUnwindSafe for WebSocket

impl !Sync for WebSocket

impl !UnwindSafe for WebSocket

impl Send for WebSocket

impl Unpin for WebSocket

impl UnsafeUnpin for WebSocket

Blanket Implementations

impl<S> TryStreamExt for WebSocket where S: TryStream + ?Sized,

impl<S, T, E> TryStream for WebSocket where S: Stream<Item = Result<T, E>> + ?Sized,

type Ok = T;
type Error = E;
fn try_poll_next(self: Pin<&mut S>, cx: &mut Context<'_>) -> Poll<Option<Result<<S as TryStream>::Ok, <S as TryStream>::Error>>>

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for WebSocket where ST: ?Sized, DT: ?Sized,

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for WebSocket where ST: ?Sized, DT: ?Sized,

impl<T> Any for WebSocket where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for WebSocket where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for WebSocket where T: ?Sized,

fn borrow_mut(&mut self) -> &mut T

impl<T> From<T> for WebSocket

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> Instrument for WebSocket

impl<T> Read<Exclusive, BecauseExclusive> for WebSocket where T: ?Sized,

impl<T> Same for WebSocket

type Output = T;

impl<T> StreamExt for WebSocket where T: Stream + ?Sized,

impl<T> WithSubscriber for WebSocket

impl<T, Item> SinkExt<Item> for WebSocket where T: Sink<Item> + ?Sized,

impl<T, U> Into<U> for WebSocket where U: From<T>,

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom<U> for WebSocket where U: Into<T>,

type Error = never;
fn try_from(value: U) -> Result<T, never>

impl<T, U> TryInto<U> for WebSocket where U: TryFrom<T>,

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

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

fn vzip(self) -> V