Struct WebSocketWriteHalf

Source
pub struct WebSocketWriteHalf { /* private fields */ }
Expand description

The write half of a WebSocket connection, generated from WebSocket::split(). This half can only send frames.

Implementations§

Source§

impl WebSocketWriteHalf

Source

pub async fn flush(&mut self) -> Result<(), WebSocketError>

Flushes incoming events from the read half. If the read half received a Ping frame, a Pong frame will be sent. If the read half received a Close frame, an echoed Close frame will be sent and the WebSocket will close. See the documentation on the WebSocket type for more details about events.

Source

pub async fn send(&mut self, frame: Frame) -> Result<(), WebSocketError>

Sends an already constructed Frame over the WebSocket connection.

This method will flush incoming events. See the documentation on the WebSocket type for more details about events.

Source

pub async fn send_text(&mut self, payload: String) -> Result<(), WebSocketError>

Sends a Text frame over the WebSocket connection, constructed from passed arguments. continuation will be false and fin will be true. To use a custom continuation or fin, construct a Frame and use WebSocketWriteHalf::send().

This method will flush incoming events. See the documentation on the WebSocket type for more details about events.

Source

pub async fn send_binary( &mut self, payload: Vec<u8>, ) -> Result<(), WebSocketError>

Sends a Binary frame over the WebSocket connection, constructed from passed arguments. continuation will be false and fin will be true. To use a custom continuation or fin, construct a Frame and use WebSocketWriteHalf::send().

This method will flush incoming events. See the documentation on the WebSocket type for more details about events.

Source

pub async fn shutdown(&mut self) -> Result<(), WebSocketError>

Shuts down the WebSocket connection without sending a Close frame. It is recommended to use the close() method instead.

Source

pub async fn close( &mut self, payload: Option<(u16, String)>, ) -> Result<(), WebSocketError>

Sends a Close frame over the WebSocket connection, constructed from passed arguments, and closes the WebSocket connection.

As per the WebSocket protocol, the server should send a Close frame in response upon receiving a Close frame. Although the write half will be closed, the server’s echoed Close frame can be read from the still open read half.

This method will flush incoming events. See the documentation on the WebSocket type for more details about events.

Source

pub async fn send_ping( &mut self, payload: Option<Vec<u8>>, ) -> Result<(), WebSocketError>

Sends a Ping frame over the WebSocket connection, constructed from passed arguments.

This method will flush incoming events. See the documentation on the WebSocket type for more details about events.

Source

pub async fn send_pong( &mut self, payload: Option<Vec<u8>>, ) -> Result<(), WebSocketError>

Sends a Pong frame over the WebSocket connection, constructed from passed arguments.

This method will flush incoming events. See the documentation on the WebSocket type for more details about events.

Trait Implementations§

Source§

impl Debug for WebSocketWriteHalf

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> ErasedDestructor for T
where T: 'static,