brotli-0.0.0.2: Brotli (RFC7932) compression and decompression
Copyright© 2016 Herbert Valerio Riedel
Maintainerhvr@gnu.org
Safe HaskellTrustworthy
LanguageHaskell2010

Codec.Compression.Brotli

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 

Instances

Instances details
Exception BrotliException Source # 
Instance details

Defined in Codec.Compression.Brotli

Methods

toException :: BrotliException -> SomeException

fromException :: SomeException -> Maybe BrotliException

displayException :: BrotliException -> String

backtraceDesired :: BrotliException -> Bool

Show BrotliException Source # 
Instance details

Defined in Codec.Compression.Brotli

Methods

showsPrec :: Int -> BrotliException -> ShowS

show :: BrotliException -> String

showList :: [BrotliException] -> ShowS

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 :: Type -> Type) 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 :: Type -> Type) 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.

newtype BrotliDecoderErrorCode Source #

Errors signalled by the Brotli decoder. Use showBrotliDecoderErrorCode to convert the numeric code into an error message.

Constructors

BrotliDecoderErrorCode Int 

Instances

Instances details
Exception BrotliDecoderErrorCode Source # 
Instance details

Defined in LibBrotli

Show BrotliDecoderErrorCode Source # 
Instance details

Defined in LibBrotli

Eq BrotliDecoderErrorCode Source # 
Instance details

Defined in LibBrotli

showBrotliDecoderErrorCode :: BrotliDecoderErrorCode -> String Source #

Convert numeric BrotliDecoderErrorCode into textual error message.

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

Instances details
Bounded CompressionLevel Source # 
Instance details

Defined in LibBrotli

Enum CompressionLevel Source # 
Instance details

Defined in LibBrotli

Read CompressionLevel Source # 
Instance details

Defined in LibBrotli

Show CompressionLevel Source # 
Instance details

Defined in LibBrotli

Methods

showsPrec :: Int -> CompressionLevel -> ShowS

show :: CompressionLevel -> String

showList :: [CompressionLevel] -> ShowS

Eq CompressionLevel Source # 
Instance details

Defined in LibBrotli

Ord 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

Instances details
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

Read CompressionWindowSize Source # 
Instance details

Defined in LibBrotli

Show CompressionWindowSize Source # 
Instance details

Defined in LibBrotli

Methods

showsPrec :: Int -> CompressionWindowSize -> ShowS

show :: CompressionWindowSize -> String

showList :: [CompressionWindowSize] -> ShowS

Eq CompressionWindowSize Source # 
Instance details

Defined in LibBrotli

Ord 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

Instances

Instances details
Read CompressionMode Source # 
Instance details

Defined in LibBrotli

Show CompressionMode Source # 
Instance details

Defined in LibBrotli

Methods

showsPrec :: Int -> CompressionMode -> ShowS

show :: CompressionMode -> String

showList :: [CompressionMode] -> ShowS

Eq CompressionMode Source # 
Instance details

Defined in LibBrotli

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)