lz4-bytes-0.1.2.0: Bindings to LZ4
Safe HaskellSafe-Inferred
LanguageHaskell2010

Lz4.Frame

Description

Compress a contiguous sequence of bytes into an LZ4 frame containing a single block.

Synopsis

Compression

compressHighlyU Source #

Arguments

:: Int

Compression level (Use 9 if uncertain)

-> Bytes

Bytes to compress

-> ByteArray 

Use HC compression to produce a frame with a single block. All optional fields (checksums, content sizes, and dictionary IDs) are omitted.

Note: Currently, this produces incorrect output when the size of the input to be compressed is greater than 4MiB. The only way to correct this function is to make it not compress large input. This can be done by setting the high bit of the size. This needs to be tested though since it is an uncommon code path.

Decompression

decompressU Source #

Arguments

:: Int

The exact size of the decompressed bytes

-> Bytes

Compressed bytes

-> Maybe ByteArray 

Decompress an LZ4 frame. The caller must know the exact size of the decompressed byte array.

Note: This currently fails if any of the optional headers are used. It is difficult to find examples of lz4 frames that actually use any of these. Open a PR with an example of an lz4 frame that fails to decode if you find one.