Skip to content
CShift0.32

Deflate

Struct · namespace System.Compression · Since 0.28

struct Deflate

Raw deflate data (RFC 1951) without a container: the format of the entries of zip files. Zlib and Gzip wrap it with a header and a checksum.

uint8[] packed = Deflate.Compress(bytes); // level 6
uint8[] smallest = Deflate.Compress(bytes, 9);
uint8[] unpacked = try Deflate.Decompress(packed);
Name Description
Compress data compressed with level 6 (the default of zlib).
Decompress The bytes of the compressed data data.
static uint8[] Compress(ReadOnlySlice<uint8> data)

data compressed with level 6 (the default of zlib).

static uint8[] Compress(ReadOnlySlice<uint8> data, int level)

data compressed with level: 0 stores it (no compression), 1 is the fastest, 9 the smallest (like zlib’s levels). Each block is written in the smallest of the three block types.

Panics when level is not 0 to 9.

static CompressionError<uint8[]> Decompress(ReadOnlySlice<uint8> data)

The bytes of the compressed data data. Bytes after the end of the stream are ignored.

Errors