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§
Sourcefn recv(&mut self) -> WasmBoxedFuture<'_, Result<Option<Frame>>>
fn recv(&mut self) -> WasmBoxedFuture<'_, Result<Option<Frame>>>
Read the next frame; Ok(None) means the peer ended the stream.
Sourcefn close(
&mut self,
frame: Option<CloseFrame>,
) -> WasmBoxedFuture<'_, Result<()>>
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".