Trait WebSocketClient

Source
pub trait WebSocketClient<ClientMsg, ServerMsg>: WebSocket<ClientMsg, ServerMsg>
where ClientMsg: Serialize + for<'a> Deserialize<'a> + Send, ServerMsg: Serialize + Debug + for<'a> Deserialize<'a> + Send,
{ // Required methods fn new(ws: WebSocket) -> Self; fn socket(&mut self) -> &mut WebSocket; // Provided methods fn send(&mut self, msg: &ClientMsg) { ... } fn callback( ws: &WebSocket, handle: &mut impl FnMut(ServerMsg) -> Option<ClientMsg>, event: MessageEvent, ) { ... } fn start( handle: impl FnMut(ServerMsg) -> Option<ClientMsg> + 'static, ) -> Option<Self> { ... } fn on_open(&self) -> Option<Box<dyn FnMut()>> { ... } }

Required Methods§

Source

fn new(ws: WebSocket) -> Self

Source

fn socket(&mut self) -> &mut WebSocket

Provided Methods§

Source

fn send(&mut self, msg: &ClientMsg)

Source

fn callback( ws: &WebSocket, handle: &mut impl FnMut(ServerMsg) -> Option<ClientMsg>, event: MessageEvent, )

Source

fn start( handle: impl FnMut(ServerMsg) -> Option<ClientMsg> + 'static, ) -> Option<Self>

Source

fn on_open(&self) -> Option<Box<dyn FnMut()>>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§