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 aRead
-like wrapper around a streamDecoder
is a layer overReadableChunks
that applies the right decompression
The following types directly support the gzip compression case:
Pending
is a non-blocking constructor for aDecoder
in case the body needs to be checked for EOFPeeked
is a buffer that keeps a few bytes available solibflate
sread_exact
calls wonβt fail
Structs§
- Brotli πA brotli decoder that reads from a
brotli::Decompressor
into aBytesMut
and emits the results as aBytes
. - A response decompressor over a non-blocking stream of chunks.
- Deflate πA deflate decoder that reads from a
deflate::Decoder
into aBytesMut
and emits the results as aBytes
. - Gzip πA gzip decoder that reads from a
libflate::gzip::Decoder
into aBytesMut
and emits the results as aBytes
. - Peeked πA buffering reader that ensures
Read
s 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
Read
able wrapper over a stream of chunks.
Enums§
- DecoderType π
- Inner π
- PeekedState π
- ReadState π
- StreamState π
Constants§
- INIT_BUFFER_SIZE π
Functions§
- poll_with_read π