livery_codec_zlib (livery v0.2.0)

View Source

Shared OTP zlib streaming backend for the gzip and deflate codecs.

The two built-in codecs differ only in the zlib WindowBits value (31 for gzip framing, 15 for zlib-wrapped DEFLATE), so the streaming machinery lives here once. stream_update/2 uses a sync flush so each producer chunk is emittable immediately.

Summary

Functions

Release the stream. Frees the underlying zlib resource.

Return the trailing bytes that finalize the stream.

Open a deflate stream with the given zlib WindowBits.

Compress a chunk and flush, returning the bytes emittable now.

Functions

stream_close(Z)

-spec stream_close(zlib:zstream()) -> ok.

Release the stream. Frees the underlying zlib resource.

stream_finish(Z)

-spec stream_finish(zlib:zstream()) -> iodata().

Return the trailing bytes that finalize the stream.

stream_init(WindowBits)

-spec stream_init(integer()) -> zlib:zstream().

Open a deflate stream with the given zlib WindowBits.

stream_update(Z, Data)

-spec stream_update(zlib:zstream(), iodata()) -> iodata().

Compress a chunk and flush, returning the bytes emittable now.