You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+117-7Lines changed: 117 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,25 +11,43 @@ Yet another websocket crate. But a fast, secure, and RFC-compliant WebSocket imp
11
11
12
12
-**Full RFC 6455 Compliance**: Complete implementation of the WebSocket protocol
13
13
-**Secure by Default**: Built-in TLS support with `rustls`
14
-
-**Advanced Compression**: Support for permessage-deflate (RFC 7692)
14
+
-**Advanced Compression**: Support for permessage-deflate (RFC 7692) with streaming compression and context takeover control
15
15
-**Zero-Copy Design**: Efficient frame processing with minimal allocations
16
-
-**Automatic Frame Management**: Handles control frames and fragmentation
16
+
-**Streaming API**: Low-level API for manual fragment control, memory-efficient processing of large messages, and fine-grained compression control
17
+
-**Automatic Frame Management**: Handles control frames and fragmentation automatically, or use `Streaming` for manual control
18
+
-**Flow Control**: Configurable backpressure boundaries and automatic fragmentation for large messages
17
19
-**Autobahn Test Suite**: Passes all test cases for both client and server modes
18
20
-**WebAssembly Support**: Works seamlessly in WASM environments for browser-based applications (both text and binary modes supported)
19
21
20
22
## About compression
21
23
22
-
yawc supports websocket compression through the [Options](https://docs.rs/yawc/latest/yawc/struct.Options.html) struct.
23
-
You can use `Options.with_compression_level(CompressLevel::fast())` in order to configure compression.
24
+
yawc supports WebSocket compression through the [Options](https://docs.rs/yawc/latest/yawc/struct.Options.html) struct with the permessage-deflate extension (RFC 7692).
The `zlib` feature is NOT mandatory to enable compression. `zlib` is configured as a feature for the [window](https://docs.rs/yawc/latest/yawc/struct.Options.html#method.with_client_max_window_bits) parameters.
32
-
By default yawc uses [flate2](https://docs.rs/flate2/) with the miniz_oxide backend. An implementation of miniz using Rust.
34
+
### Advanced Compression Features
35
+
36
+
-**Streaming compression**: Compress large messages incrementally without buffering (available via `Streaming` API)
37
+
-**Context takeover control**: Reset compression state between messages for consistent memory usage
38
+
-**Configurable compression levels**: Balance between compression ratio and CPU usage
The `zlib` feature is NOT mandatory to enable compression. `zlib` is only required for the [window bits](https://docs.rs/yawc/latest/yawc/struct.Options.html#method.with_client_max_window_bits) configuration parameters.
50
+
By default yawc uses [flate2](https://docs.rs/flate2/) with the miniz_oxide backend - a pure Rust implementation of deflate.
33
51
34
52
## Upgrading or Migrating?
35
53
@@ -213,6 +231,48 @@ futures = { version = "0.3", default-features = false, features = ["std"] }
213
231
214
232
## Advanced Features
215
233
234
+
### Streaming API
235
+
236
+
For advanced use cases requiring manual control over frame fragmentation, yawc provides a low-level `Streaming` API:
237
+
238
+
```rust
239
+
useyawc::{WebSocket, Frame, OpCode};
240
+
usefutures::{SinkExt, StreamExt};
241
+
242
+
// Convert WebSocket to Streaming for manual fragment control
.server_no_context_takeover() // Reset compression context after each message
288
+
.client_no_context_takeover() // Optimize memory for client side
228
289
.with_client_max_window_bits(11) // Control compression window (requires zlib feature)
229
290
)
230
291
.await?;
231
292
```
232
293
294
+
**Context Takeover Options:**
295
+
296
+
The `no_context_takeover` options control how compression state is managed between messages:
297
+
298
+
-**With context takeover (default)**: The compression dictionary is maintained across messages, providing better compression ratios for similar data but using more memory over time.
299
+
300
+
-**Without context takeover**: The compression dictionary is reset after each message, trading compression efficiency for consistent memory usage. Ideal for:
301
+
- Long-lived connections where memory growth is a concern
0 commit comments