brotli-0.0.0.0: Brotli (RFC7932) compression and decompression

Copyright© 2016 Herbert Valerio Riedel
Maintainerhvr@gnu.org
Safe HaskellTrustworthy
LanguageHaskell2010

Codec.Compression.Brotli

Contents

Description

Compression and decompression of data streams in the "Brotli" format (RFC7932)

Synopsis

Simple (de)compression with default parameters

compress :: ByteString -> ByteString Source #

Compress lazy ByteString into Brotli stream using defaultCompressParams.

decompress :: ByteString -> ByteString Source #

Decompress lazy ByteString from a Brotli stream.

newtype BrotliException Source #

Exception thrown on decoding errors or internal erros

Note that BrotliDecoderErrorCode will be thrown instead of BrotliException when possible.

Constructors

BrotliException String 

Extended API with control over parameters

compressWith :: CompressParams -> ByteString -> ByteString Source #

Like compress but with the ability to specify various compression parameters. Typical usage:

compressWith defaultCompressParams { compress... = ... }

decompressWith :: DecompressParams -> ByteString -> ByteString Source #

Like decompress but with the ability to specify various decompression parameters. Typical usage:

decompressWith defaultDecompressParams { decompress... = ... }

Monadic incremental (de)compression API

See zlib's incremental API documentation for more information.

Compression

data CompressStream m Source #

Constructors

CompressInputRequired (m (CompressStream m)) (ByteString -> m (CompressStream m))

Compression process requires input to proceed. You can either flush the stream (first field), supply an input chunk (second field), or signal the end of input (via empty chunk).

CompressOutputAvailable !ByteString (m (CompressStream m))

Output chunk available.

CompressStreamEnd 

compressIO :: CompressParams -> IO (CompressStream IO) Source #

Incremental compression in the IO monad.

compressST :: CompressParams -> ST s (CompressStream (ST s)) Source #

Incremental compression in the lazy ST monad.

Decompression

data DecompressStream m Source #

Constructors

DecompressInputRequired (ByteString -> m (DecompressStream m))

Decoding process requires input to proceed. An empty ByteString chunk signals end of input.

DecompressOutputAvailable !ByteString (m (DecompressStream m))

Decompressed output chunk available.

DecompressStreamEnd ByteString

Decoded stream is finished. Any unconsumed leftovers from the input stream are returned via the ByteString field

DecompressStreamError !BrotliDecoderErrorCode 

decompressIO :: DecompressParams -> IO (DecompressStream IO) Source #

Incremental decompression in the IO monad.

decompressST :: DecompressParams -> ST s (DecompressStream (ST s)) Source #

Incremental decompression in the lazy ST monad.

Parameters

Compression parameters

defaultCompressParams :: CompressParams Source #

The default set of parameters for compression. This is typically used with the compressWith function with specific parameters overridden.

data CompressParams Source #

Set of parameters for compression. The defaults are defaultCompressParams.

compressSizeHint :: CompressParams -> Word32 Source #

CompressParams field: Estimated total input size. The default value is 0, which means that the total input size is unknown.

data CompressionLevel Source #

Compression quality setting

Instances
Bounded CompressionLevel Source # 
Instance details

Defined in LibBrotli

Enum CompressionLevel Source # 
Instance details

Defined in LibBrotli

Eq CompressionLevel Source # 
Instance details

Defined in LibBrotli

Ord CompressionLevel Source # 
Instance details

Defined in LibBrotli

Read CompressionLevel Source # 
Instance details

Defined in LibBrotli

Show CompressionLevel Source # 
Instance details

Defined in LibBrotli

data CompressionWindowSize Source #

Recommended sliding LZ77 window size.

The encoder may reduce this value (if e.g. input is much smaller than window size).

Instances
Bounded CompressionWindowSize Source # 
Instance details

Defined in LibBrotli

Enum CompressionWindowSize Source #

This Enum instance is offset by 10.

>>> toEnum CompressionWindowBits10
10
>>> fromEnum 22 :: CompressionWindowSize
CompressionWindowBits22
Instance details

Defined in LibBrotli

Eq CompressionWindowSize Source # 
Instance details

Defined in LibBrotli

Ord CompressionWindowSize Source # 
Instance details

Defined in LibBrotli

Read CompressionWindowSize Source # 
Instance details

Defined in LibBrotli

Show CompressionWindowSize Source # 
Instance details

Defined in LibBrotli

data CompressionMode Source #

Encoding profile

Constructors

CompressionModeGeneric

Format-agnostic default mode

CompressionModeText

UTF-8 formatted text data

CompressionModeFont

Compression mode used in WOFF 2.0

Decompression parameters

defaultDecompressParams :: DecompressParams Source #

The default set of parameters for decompression. This is typically used with the decompressWith function with specific parameters overridden.

data DecompressParams Source #

Set of parameters for decompression. The defaults are defaultDecompressParams.

decompressDisableRingBufferReallocation :: DecompressParams -> Bool Source #

DecompressParams field: If True, ring buffer is allocated according to window size, despite the real size of the content. (default: False)