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

Lz4.Block

Description

Compress a contiguous sequence of bytes into a single LZ4 block. These functions do not perform any framing.

Synopsis

Compression

compress Source #

Arguments

:: Int

Acceleration Factor (Use 1 if uncertain)

-> Bytes

Bytes to compress

-> Bytes 

Compress bytes using LZ4. A higher acceleration factor increases speed but decreases compression. This function has undefined behavior on byte sequences larger than 2,113,929,216 bytes. This calls LZ4_compress_default.

compressU Source #

Arguments

:: Int

Acceleration Factor (Use 1 if uncertain)

-> Bytes

Bytes to compress

-> ByteArray 

Variant of compress with an unsliced result.

compressHighly Source #

Arguments

:: Int

Compression level (Use 9 if uncertain)

-> Bytes

Bytes to compress

-> Bytes 

Compress bytes using LZ4's HC algorithm. This is slower than compress but provides better compression. A higher compression level increases compression but decreases speed. This function has undefined behavior on byte sequences larger than 2,113,929,216 bytes. This calls LZ4_compress_HC.

compressHighlyU Source #

Arguments

:: Int

Compression level (Use 9 if uncertain)

-> Bytes

Bytes to compress

-> ByteArray 

Variant of compressHighly with an unsliced result.

Decompression

decompress Source #

Arguments

:: Int

Expected length of decompressed bytes

-> Bytes

Compressed bytes

-> Maybe Bytes 

Decompress a byte sequence. Fails if the actual decompressed result does not match the given expected length.

decompressU Source #

Arguments

:: Int

Expected length of decompressed bytes

-> Bytes

Compressed bytes

-> Maybe ByteArray 

Variant of decompress with an unsliced result.

Unsafe Compression

compressInto Source #

Arguments

:: Int

Acceleration Factor (Use 1 if uncertain)

-> Bytes

Bytes to compress

-> MutableByteArray s

Destination buffer

-> Int

Offset into destination buffer

-> Int

Bytes remaining in destination buffer

-> ST s Int

Next available offset in destination buffer

Compress bytes using LZ4, pasting the compressed bytes into the mutable byte array at the specified offset.

Precondition: There must be at least requiredBufferSize (Bytes.length src) bytes available starting from the offset in the destination buffer. This is checked, and this function will throw an exception if this invariant is violated.

Computing buffer size

requiredBufferSize :: Int -> Int Source #

Copied from the LZ4_COMPRESSBOUND macro lz4.h to avoid using FFI for simple arithmetic. Make sure this stays in sync with the macro.