Skip to main content

Module deflate

Module deflate 

Source
Expand description

RFC 7692 permessage-deflate: negotiation and per-message codec.

Memory policy, chosen for tens of thousands of mostly idle connections:

  • Server → client: the server always declares server_no_context_takeover (allowed by RFC 7692 §7.1.1.1 regardless of the offer). Compression state is then not needed between messages, so compressors come from a process-wide pool instead of being held per connection.
  • Client → server: a decompressor is allocated lazily, on the first compressed message. With client_no_context_takeover (requested by the client, or imposed by configuration per §7.1.1.2) it is reset after every message.
  • server_max_window_bits < 15 cannot be honoured by the pure-Rust DEFLATE backend, so such offers are declined (the connection then simply runs uncompressed, which RFC 7692 and OCPP both allow).

Structs§

DeflateConfig
DeflateParams
Parameters agreed during the handshake.
Inflater
Per-connection decompressor for messages received from the peer.

Enums§

InflateError

Functions§

accept_client_response
Client side: interprets the server’s Sec-WebSocket-Extensions response.
compress_message
Compresses one message without context takeover, using a pooled compressor.
negotiate_server
Server side: picks the first acceptable permessage-deflate offer and returns the agreed parameters and the Sec-WebSocket-Extensions response value.