Skip to main content

WsConn

Trait WsConn 

Source
pub trait WsConn: Send {
    // Required methods
    fn send_text(
        &mut self,
        text: String,
    ) -> impl Future<Output = Result<(), WsError>> + Send;
    fn send_pong(
        &mut self,
        payload: Bytes,
    ) -> impl Future<Output = Result<(), WsError>> + Send;
    fn recv(
        &mut self,
    ) -> impl Future<Output = Result<Option<WsFrame>, WsError>> + Send;
    fn close(&mut self) -> impl Future<Output = Result<(), WsError>> + Send;
}
Expand description

A full-duplex WebSocket connection.

This trait is intentionally minimal so tests can use a fake connection without depending on a concrete WebSocket implementation.

Required Methods§

Source

fn send_text( &mut self, text: String, ) -> impl Future<Output = Result<(), WsError>> + Send

Send a text frame.

Source

fn send_pong( &mut self, payload: Bytes, ) -> impl Future<Output = Result<(), WsError>> + Send

Send a pong control frame with the supplied ping payload.

Source

fn recv( &mut self, ) -> impl Future<Output = Result<Option<WsFrame>, WsError>> + Send

Receive the next frame.

Source

fn close(&mut self) -> impl Future<Output = Result<(), WsError>> + Send

Close the connection.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§