pub trait WebSocketConnection: WasmCompatSend + WasmCompatSync {
// Required methods
fn send(
&mut self,
frame: Frame,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + '_>>;
fn recv(
&mut self,
) -> Pin<Box<dyn Future<Output = Result<Option<Frame>, Error>> + Send + '_>>;
fn close(
&mut self,
frame: Option<CloseFrame>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + '_>>;
}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 send(
&mut self,
frame: Frame,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + '_>>
fn send( &mut self, frame: Frame, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + '_>>
Write one frame.
Trait Implementations§
Source§impl WebSocketConnection for Box<dyn WebSocketConnection>
impl WebSocketConnection for Box<dyn WebSocketConnection>
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".