Module net::decoder

source Β·
Expand description

Adapted from an implementation in reqwest. A potentially non-blocking response decoder.

The decoder wraps a stream of chunks and produces a new stream of decompressed chunks. The decompressed chunks aren’t guaranteed to align to the compressed ones.

If the response is plaintext then no additional work is carried out. Chunks are just passed along.

If the response is gzip, then the chunks are decompressed into a buffer. Slices of that buffer are emitted as new chunks.

This module consists of a few main types:

  • ReadableChunks is a Read-like wrapper around a stream
  • Decoder is a layer over ReadableChunks that applies the right decompression

The following types directly support the gzip compression case:

  • Pending is a non-blocking constructor for a Decoder in case the body needs to be checked for EOF
  • Peeked is a buffer that keeps a few bytes available so libflates read_exact calls won’t fail

Structs§

  • Brotli πŸ”’
    A brotli decoder that reads from a brotli::Decompressor into a BytesMut and emits the results as a Bytes.
  • A response decompressor over a non-blocking stream of chunks.
  • Deflate πŸ”’
    A deflate decoder that reads from a deflate::Decoder into a BytesMut and emits the results as a Bytes.
  • Gzip πŸ”’
    A gzip decoder that reads from a libflate::gzip::Decoder into a BytesMut and emits the results as a Bytes.
  • Peeked πŸ”’
    A buffering reader that ensures Reads return at least a few bytes.
  • Pending πŸ”’
    A future attempt to poll the response body for EOF so we know whether to use gzip or not.
  • A Readable wrapper over a stream of chunks.

Enums§

Constants§

Functions§