Skip to main content

Module zlib

Module zlib 

Source
Expand description

The zlib format (RFC 1950): a two-byte header, a DEFLATE stream and an Adler-32 trailer.

use pltrs_codec::{zlib, CompressionLevel};

let packed = zlib::compress(b"hello, hello, hello", CompressionLevel::DEFAULT)?;
assert_eq!(&packed[..2], [0x78, 0x9C]);
assert_eq!(zlib::decompress(&packed)?, b"hello, hello, hello");

Structs§

Compressor
Compresses stream after stream with the same tables, for writers of many streams (PDF’s): each stream is the one compress_with writes, without allocating and clearing the compressor’s 300 KiB of tables anew for each.

Enums§

ZlibError
An error found while decoding a zlib stream.

Functions§

compress
Compresses data into a new zlib stream at level, as zlib-ng’s compress2 does.
compress_into
Appends the zlib compression of data at level to out.
compress_with
Compresses data into a new zlib stream as zlib-ng does with options.
decompress
Decompresses a complete zlib stream; trailing bytes are an error.
decompress_into
Decompresses the zlib stream at the start of input, appending at most limit bytes to out, and returns the number of input bytes the stream occupied (bytes after it are left alone).
decompress_with_limit
Like decompress, but fails instead of producing more than limit bytes.