std.gzip
Compresses and decompresses data in the format of gzip (RFC 1952), the deflate of RFC 1951 with a header and a check: the files .gz, and the bodies of HTTP with Content-Encoding gzip. inflate() reads deflate alone, as a zip holds it, and crc32() gives the check of gzip and of zip.
import std.gzip
list<u8> packed = gzip.compress("hello, hello, hello".bytes())
string text = string(gzip.decompress(packed))The guide: Networking and HTTP.
Made from the documentation in the sources of the library.
#Functions
#compress
list<u8> compress(list<u8> data)The data compressed in the format of gzip, which any gzip reads. It uses only the fixed codes of deflate, so the result is somewhat larger than the one of the gzip command.
#decompress
list<u8> decompress(list<u8> data)The data of a gzip, decompressed; a gzip of several members, one after the other, gives them joined. Throws when the data are not gzip, or are damaged or cut: the CRC-32 and the size are checked. For data that come from the network, decompressUpTo() sets a limit.
#decompressUpTo
list<u8> decompressUpTo(list<u8> data, i64 limit)As decompress(), but throws when the result would be larger than limit bytes: for data that come from the network, where a few kilobytes can become gigabytes.
#inflate
list<u8> inflate(list<u8> data, i64 limit)The data of deflate decompressed, without the header and the check of gzip, as a zip holds them. Throws when the data are damaged or cut, or when the result would be larger than limit bytes.
#crc32
u32 crc32(list<u8> data)The CRC-32 of the data, the check of gzip and of zip: "123456789" gives 0xCBF43926.