[−][src]Crate ws_stream_wasm
A convenience layer for using WebSockets from WebAssembly. It implements a futures Stream/Sink and tokio AsyncRead/AsyncWrite on top of the web-sys interface WebSocket.
This allows you to communicate between your server and a browser wasm module transparently without worrying about the underlying protocol. You can use tokio codec to get framed messages of any type that implements serde::Serialize.
This library tries to work with [async_await] wherever possible, with the exemption of WsStream because tokio is on futures 0.1. It requires a nightly compiler for now.
For examples please have a look at JsWebSocket and WsStream.
Structs
ChunkStream | Turn a stream/sink of binary messages into a stream of bytes (AsyncRead/AsyncWrite). |
JsMsgEvent | A wrapper around the |
JsWebSocket | A wrapper around web_sys::WebSocket to make it more rust idiomatic. It does not provide any extra functionality over the wrapped WebSocket object. |
WsErr | The error type for errors happening in |
WsStream | A tokio AsyncRead/AsyncWrite representing a WebSocket connection. It only supports binary mode. Contrary to the rest of this library, this will work on types from futures 0.1 instead of 0.3. This is because tokio currently is on futures 0.1, so the stream returned from a codec will be 0.1. |
Enums
JsMsgEvtData | Data contained in a MessageEvent. See: Html5 specs |
WsErrKind | The different kind of errors that can happen when you use the |
WsReadyState | Indicates the state of a Websocket connection. The only state in which it's valid to send and receive messages is OPEN. |
Functions
future_event | Turn a JavaScript callback type interface into a future. The future will resolve when the callback gets called. There is currently no support for calbacks that need to take parameters. |