Skip to main content

WebSocketConnection

Trait WebSocketConnection 

Source
pub trait WebSocketConnection: WasmCompatSend + WasmCompatSync {
    // Required methods
    fn send(&mut self, frame: Frame) -> WasmBoxedFuture<'_, Result<()>>;
    fn recv(&mut self) -> WasmBoxedFuture<'_, Result<Option<Frame>>>;
    fn close(
        &mut self,
        frame: Option<CloseFrame>,
    ) -> WasmBoxedFuture<'_, Result<()>>;
}
Available on crate feature websocket only.
Expand description

One open websocket connection, usable as a trait object. Calls are sequential: sessions must not poll send and receive concurrently. WASM-compatible bounds preserve the containing session’s thread-safety contract.

Required Methods§

Source

fn send(&mut self, frame: Frame) -> WasmBoxedFuture<'_, Result<()>>

Write one frame.

Source

fn recv(&mut self) -> WasmBoxedFuture<'_, Result<Option<Frame>>>

Read the next frame; Ok(None) means the peer ended the stream.

Source

fn close( &mut self, frame: Option<CloseFrame>, ) -> WasmBoxedFuture<'_, Result<()>>

Completes a close handshake. Callers must avoid repeated closes; backends may return an error for an already closed socket.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§