snappy-framed-0.1.0.0: Decompression for framed Snappy streams

Safe HaskellSafe
LanguageHaskell2010

Codec.Compression.Snappy.Framed.SNZip

Description

A format developed as part of the snzip application.

From the docs:

The first three bytes are magic characters 'SNZ'.

The fourth byte is the file format version. It is 0x01.

The fifth byte is the order of the block size. The input data is
divided into fixed-length blocks and each block is compressed by
snappy. When it is 16 (default value), the block size is 16th power of
2; 64 kilobytes.

The rest is pairs of a compressed data length and a compressed data
block The compressed data length is encoded as
snappy::Varint::Encode32() does. If the length is zero, it is the end
of data.

Though the rest after the end of data is ignored for now, they may be
continuously read as a next compressed file as gzip does.

Note that the uncompressed length of each compressed data block must
be less than or equal to the block size specified by the fifth byte.

Example encoding of the string "foobar\n":

00000000  53 4e 5a 01 10 09 07 18  66 6f 6f 62 61 72 0a 00  |SNZ.....foobar..|

Reference: https://github.com/kubo/snzip

Synopsis

Documentation

parseHeader :: Parser () Source

Attempt to parse the header. If the header exists, it will be consumed. If not, the parser will fail.

parseBlock :: Parser ByteString Source

Parse a single block of the compressed bytestream, returning a segment of the uncompressed stream.