Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Compress a contiguous sequence of bytes into a single LZ4 block. These functions do not perform any framing.
Synopsis
- compress :: Int -> Bytes -> Bytes
- compressU :: Int -> Bytes -> ByteArray
- compressHighly :: Int -> Bytes -> Bytes
- compressHighlyU :: Int -> Bytes -> ByteArray
- decompress :: Int -> Bytes -> Maybe Bytes
- decompressU :: Int -> Bytes -> Maybe ByteArray
- compressInto :: Int -> Bytes -> MutableByteArray s -> Int -> Int -> ST s Int
- requiredBufferSize :: Int -> Int
Compression
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
.
Variant of compress
with an unsliced result.
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
.
Variant of compressHighly
with an unsliced result.
Decompression
Decompress a byte sequence. Fails if the actual decompressed result does not match the given expected length.
Variant of decompress
with an unsliced result.
Unsafe Compression
:: 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
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.requiredBufferSize
(Bytes.length src)
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.