Deflate
Struct · namespace System.Compression · Since 0.28
struct DeflateRaw 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 6uint8[] smallest = Deflate.Compress(bytes, 9);uint8[] unpacked = try Deflate.Decompress(packed);Static methods
Section titled “Static methods”| Name | Description |
|---|---|
Compress |
data compressed with level 6 (the default of zlib). |
Decompress |
The bytes of the compressed data data. |
Compress
Section titled “Compress”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.
Decompress
Section titled “Decompress”static CompressionError<uint8[]> Decompress(ReadOnlySlice<uint8> data)The bytes of the compressed data data. Bytes after the end of the stream are ignored.
Errors
CompressionError.InvalidData:datais not valid deflate data.CompressionError.Truncated:dataends before the end of the stream.