1 unstable release

0.1.0 Nov 15, 2023

#261 in WebSocket



Low-level WebSocket (RFC 6455) library which implements WebSocket frame encoding and decoding.

  • No memory allocations. Only minimal state is kept in memory, all payload content remains in user-supplied buffers. The crate is no_std-friendly.
  • No input or output. It only helps you to turn raw bytes into sensible structures and back.
  • Frame payloads may be divided into arbitrary chunks.
  • No validation - you can set or access reserved bits or opcodes if needed.
  • Encoder and decoder states are rather small. You can shrink the decoder further by opting out of large_frames crate feature.
  • Masking should re reasonably fast and SIMD-friendly. You can adjust crate features to opt out the optimisation (for smaller code) or to adjust SIMD slice size.
  • Encoder and decoder instances are const-initialisable.

It is also user's job to handle pings, HTTP upgrades, masking and close frames properly. There is no automatic assembling of messages from frames or splitting messages into frames. WebSocket text frames are handled the same way as binary frames - you need to convert to a string yourself.


  • encode_frame - Encode one simple text WebSocket message and decode it with Tungstenite.
  • decode_frame - Encode one simple text message with Tungstenite and decode it with this library. Though no control or fragmented messages actually appears in this case, it tried to handle them properly to server as a template for other code.
  • mirror_client - Connect to a WebSocket server that is listening on and send back all frames which come from it, announcing each frame on console. Uses Tokio and hyper v1. Demonstrates how to validate incoming frames.


~10K SLoC