Blitz
Lightweight stream-based WebSocket implementation for Rust, inspired from Tungstenite.
use TcpListener;
use spawn;
use accept;
/// A WebSocket echo server
Take a look at the examples section to see how to write a simple client/server.
Blitz
NOTE: blitz exposes primitives, not batteries. For a higher-level abstraction with full async support and production-ready integrations, consider using frameworks like tokio-tungstenite instead. tokio-tungstenite.
Introduction
Blitz implements key parts of RFC6455, including:
- WebSocket framing, handshake, masking, and control frames
- RFC-compliant close codes and opcodes
- HTTP 1.1 request parsing (handshake only)
- TLS via native-tls or rustls
- Optional permessage-deflate compression (via flate2)
Features
Blitz supports multiple optional TLS and utility features via Cargo:
native-tlsnative-tls-vendoredrustls-tls-native-rootsrustls-tls-webpki-roots
Choose the one that is appropriate for your needs.
By default no TLS feature is activated, so make sure you use one of the TLS features, otherwise you won't be able to communicate with the TLS endpoints.
Design Goals
- Zero async: Fully synchronous, blocking API
- Explicit handshake logic and frame state machine
- No hidden abstractions, futures, or macros
- Easy to audit, debug, and extend
Example Projects
examples/echo.rs: Simple WebSocket echo server examples/client.rs: Basic WebSocket client using TcpStream examples/tls.rs: Connecting via TLS with native-tls or rustls
Compression Support
Blitz supports permessage-deflate via the flate2 crate and the rust_backend feature.
Compression is not enabled by default. You must explicitly negotiate it during the handshake if you want it.
Testing
- Internal unit tests cover most framing and handshake logic.
- Autobahn Test Suite compatibility is being targeted (WIP).
- CI planned for protocol compliance and memory safety.
Contributing
Blitz is experimental but aims for clarity and completeness. Contributions are welcome — especially:
- Autobahn Test Suite passes
- Advanced compression support
- More TLS options (e.g. ALPN)
- Streaming upgrade support
Please file issues or PRs on GitHub.
License
Licensed under either of:
- MIT License
- Apache License, Version 2.0 at your option.