Copyright | © 2019 Herbert Valerio Riedel |
---|---|
Maintainer | hvr@gnu.org |
Safe Haskell | Trustworthy |
Language | Haskell2010 |
Compression and decompression of data streams in the "Brotli" format (RFC7932)
Synopsis
- compress :: MonadIO m => ByteString m r -> ByteString m r
- decompress :: MonadIO m => ByteString m r -> ByteString m (ByteString m r)
- decompress_ :: MonadIO m => ByteString m r -> ByteString m r
- compressWith :: MonadIO m => CompressParams -> ByteString m r -> ByteString m r
- defaultCompressParams :: CompressParams
- data CompressParams
- compressLevel :: CompressParams -> CompressionLevel
- compressWindowSize :: CompressParams -> CompressionWindowSize
- compressMode :: CompressParams -> CompressionMode
- compressSizeHint :: CompressParams -> Word32
- data CompressionLevel
- data CompressionWindowSize
- = CompressionWindowBits10
- | CompressionWindowBits11
- | CompressionWindowBits12
- | CompressionWindowBits13
- | CompressionWindowBits14
- | CompressionWindowBits15
- | CompressionWindowBits16
- | CompressionWindowBits17
- | CompressionWindowBits18
- | CompressionWindowBits19
- | CompressionWindowBits20
- | CompressionWindowBits21
- | CompressionWindowBits22
- | CompressionWindowBits23
- | CompressionWindowBits24
- data CompressionMode
- decompressWith :: MonadIO m => DecompressParams -> ByteString m r -> ByteString m (ByteString m r)
- defaultDecompressParams :: DecompressParams
- data DecompressParams
- decompressDisableRingBufferReallocation :: DecompressParams -> Bool
Simple interface
:: MonadIO m | |
=> ByteString m r | compressed stream |
-> ByteString m r | uncompressed stream |
Compress into a Brotli compressed stream.
:: MonadIO m | |
=> ByteString m r | compressed stream |
-> ByteString m (ByteString m r) | uncompressed stream |
Decompress a compressed Brotli stream.
The monadic return value is a stream representing the possibly
unconsumed leftover data from the input stream; see also decompress_
.
:: MonadIO m | |
=> ByteString m r | compressed stream |
-> ByteString m r | uncompressed stream |
Convenience wrapper around decompress
which fails eagerly if
the compressed stream contains any trailing data
Extended interface
Compression
:: MonadIO m | |
=> CompressParams | |
-> ByteString m r | uncompressed stream |
-> ByteString m r | compressed stream |
Like compress
but with the ability to specify various compression
parameters. Typical usage:
compressWith defaultCompressParams { compress... = ... }
defaultCompressParams :: CompressParams #
The default set of parameters for compression. This is typically
used with the compressWith
function with specific parameters
overridden.
data CompressParams #
Set of parameters for compression. The defaults are defaultCompressParams
.
compressLevel :: CompressParams -> CompressionLevel #
CompressParams
field: See documentation of CompressionLevel
compressWindowSize :: CompressParams -> CompressionWindowSize #
CompressParams
field: See documentation of CompressionWindowSize
compressMode :: CompressParams -> CompressionMode #
CompressParams
field: See documentation of CompressionMode
compressSizeHint :: CompressParams -> Word32 #
CompressParams
field: Estimated total input size. The default value is 0
, which means that the total input size is unknown.
data CompressionLevel #
Compression quality setting
CompressionLevel0 | fastest/lowest compression level |
CompressionLevel1 | |
CompressionLevel2 | |
CompressionLevel3 | |
CompressionLevel4 | |
CompressionLevel5 | |
CompressionLevel6 | |
CompressionLevel7 | |
CompressionLevel8 | |
CompressionLevel9 | |
CompressionLevel10 | |
CompressionLevel11 | slowest/highest compression level (default) |
Instances
data CompressionWindowSize #
Recommended sliding LZ77 window size.
The encoder may reduce this value (if e.g. input is much smaller than window size).
CompressionWindowBits10 | 1008 bytes |
CompressionWindowBits11 | 2032 bytes |
CompressionWindowBits12 | 4080 bytes |
CompressionWindowBits13 | 8176 bytes |
CompressionWindowBits14 | 16368 bytes |
CompressionWindowBits15 | 32752 bytes |
CompressionWindowBits16 | 65520 bytes |
CompressionWindowBits17 | 131056 bytes |
CompressionWindowBits18 | 262128 bytes |
CompressionWindowBits19 | 524272 bytes |
CompressionWindowBits20 | 1048560 bytes |
CompressionWindowBits21 | 2097136 bytes |
CompressionWindowBits22 | 4194288 bytes (default) |
CompressionWindowBits23 | 8388592 bytes |
CompressionWindowBits24 | 16777200 bytes |
Instances
data CompressionMode #
Encoding profile
CompressionModeGeneric | Format-agnostic default mode |
CompressionModeText | UTF-8 formatted text data |
CompressionModeFont | Compression mode used in WOFF 2.0 |
Instances
Eq CompressionMode | |
Defined in LibBrotli (==) :: CompressionMode -> CompressionMode -> Bool # (/=) :: CompressionMode -> CompressionMode -> Bool # | |
Read CompressionMode | |
Defined in LibBrotli | |
Show CompressionMode | |
Defined in LibBrotli showsPrec :: Int -> CompressionMode -> ShowS # show :: CompressionMode -> String # showList :: [CompressionMode] -> ShowS # |
Decompression
:: MonadIO m | |
=> DecompressParams | |
-> ByteString m r | compressed stream |
-> ByteString m (ByteString m r) | uncompressed stream |
Like decompress
but with the ability to specify various decompression
parameters. Typical usage:
decompressWith defaultDecompressParams { decompress... = ... }
defaultDecompressParams :: DecompressParams #
The default set of parameters for decompression. This is
typically used with the decompressWith
function with specific
parameters overridden.
data DecompressParams #
Set of parameters for decompression. The defaults are
defaultDecompressParams
.
decompressDisableRingBufferReallocation :: DecompressParams -> Bool #
DecompressParams
field: If True
, ring buffer is allocated according to window size, despite the real size of the content. (default: False
)