| Copyright | © 2015 Herbert Valerio Riedel |
|---|---|
| License | BSD3 |
| Maintainer | hvr@gnu.org |
| Stability | experimental |
| Safe Haskell | None |
| Language | Haskell2010 |
Codec.Compression.Lzma
Contents
Description
Compression and decompression of data streams in the lzma/xz format
See also the XZ Utils home page: http://tukaani.org/xz/
Synopsis
- compress :: ByteString -> ByteString
- decompress :: ByteString -> ByteString
- compressWith :: CompressParams -> ByteString -> ByteString
- decompressWith :: DecompressParams -> ByteString -> ByteString
- data CompressStream m
- = CompressInputRequired (m (CompressStream m)) (ByteString -> m (CompressStream m))
- | CompressOutputAvailable !ByteString (m (CompressStream m))
- | CompressStreamEnd
- compressIO :: CompressParams -> IO (CompressStream IO)
- compressST :: CompressParams -> ST s (CompressStream (ST s))
- data DecompressStream m
- decompressIO :: DecompressParams -> IO (DecompressStream IO)
- decompressST :: DecompressParams -> ST s (DecompressStream (ST s))
- data LzmaRet
- defaultCompressParams :: CompressParams
- data CompressParams
- compressIntegrityCheck :: CompressParams -> IntegrityCheck
- compressLevel :: CompressParams -> CompressionLevel
- compressLevelExtreme :: CompressParams -> Bool
- data IntegrityCheck
- data CompressionLevel
- defaultDecompressParams :: DecompressParams
- data DecompressParams
- decompressTellNoCheck :: DecompressParams -> Bool
- decompressTellUnsupportedCheck :: DecompressParams -> Bool
- decompressTellAnyCheck :: DecompressParams -> Bool
- decompressConcatenated :: DecompressParams -> Bool
- decompressAutoDecoder :: DecompressParams -> Bool
- decompressMemLimit :: DecompressParams -> Word64
Simple (de)compression
compress :: ByteString -> ByteString #
Compress lazy ByteString into .xz format using defaultCompressParams.
decompress :: ByteString -> ByteString #
Decompress lazy ByteString from the .xz format
Extended API with control over parameters
compressWith :: CompressParams -> ByteString -> ByteString #
Like compress but with the ability to specify various compression
parameters. Typical usage:
compressWith defaultCompressParams { compress... = ... }decompressWith :: DecompressParams -> ByteString -> ByteString #
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 #
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) #
Incremental compression in the IO monad.
compressST :: CompressParams -> ST s (CompressStream (ST s)) #
Incremental compression in the lazy ST monad.
Decompression
data DecompressStream m #
Constructors
| DecompressInputRequired (ByteString -> m (DecompressStream m)) | Decoding process requires input to proceed. An empty |
| 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 |
| DecompressStreamError !LzmaRet |
decompressIO :: DecompressParams -> IO (DecompressStream IO) #
Incremental decompression in the IO monad.
decompressST :: DecompressParams -> ST s (DecompressStream (ST s)) #
Incremental decompression in the lazy ST monad.
Constructors
| LzmaRetOK | |
| LzmaRetStreamEnd | |
| LzmaRetUnsupportedCheck | |
| LzmaRetGetCheck | |
| LzmaRetMemError | |
| LzmaRetMemlimitError | |
| LzmaRetFormatError | |
| LzmaRetOptionsError | |
| LzmaRetDataError | |
| LzmaRetBufError | |
| LzmaRetProgError |
Parameters
Compression parameters
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.
Instances
| Eq CompressParams # | |
Defined in LibLzma Methods (==) :: CompressParams -> CompressParams -> Bool # (/=) :: CompressParams -> CompressParams -> Bool # | |
| Show CompressParams # | |
Defined in LibLzma Methods showsPrec :: Int -> CompressParams -> ShowS # show :: CompressParams -> String # showList :: [CompressParams] -> ShowS # | |
compressIntegrityCheck :: CompressParams -> IntegrityCheck #
CompressParams field: Specify type of integrity check
compressLevel :: CompressParams -> CompressionLevel #
CompressParams field: See documentation of CompressionLevel
compressLevelExtreme :: CompressParams -> Bool #
CompressParams field: Enable slower variant of the
lzmaCompLevel preset, see xz(1)
man-page for details.
data IntegrityCheck #
Integrity check type (only supported when compressing .xz files)
Constructors
| IntegrityCheckNone | disable integrity check (not recommended) |
| IntegrityCheckCrc32 | CRC32 using the polynomial from IEEE-802.3 |
| IntegrityCheckCrc64 | CRC64 using the polynomial from ECMA-182 |
| IntegrityCheckSha256 | SHA-256 |
Instances
| Eq IntegrityCheck # | |
Defined in LibLzma Methods (==) :: IntegrityCheck -> IntegrityCheck -> Bool # (/=) :: IntegrityCheck -> IntegrityCheck -> Bool # | |
| Ord IntegrityCheck # | |
Defined in LibLzma Methods compare :: IntegrityCheck -> IntegrityCheck -> Ordering # (<) :: IntegrityCheck -> IntegrityCheck -> Bool # (<=) :: IntegrityCheck -> IntegrityCheck -> Bool # (>) :: IntegrityCheck -> IntegrityCheck -> Bool # (>=) :: IntegrityCheck -> IntegrityCheck -> Bool # max :: IntegrityCheck -> IntegrityCheck -> IntegrityCheck # min :: IntegrityCheck -> IntegrityCheck -> IntegrityCheck # | |
| Read IntegrityCheck # | |
Defined in LibLzma Methods readsPrec :: Int -> ReadS IntegrityCheck # readList :: ReadS [IntegrityCheck] # | |
| Show IntegrityCheck # | |
Defined in LibLzma Methods showsPrec :: Int -> IntegrityCheck -> ShowS # show :: IntegrityCheck -> String # showList :: [IntegrityCheck] -> ShowS # | |
data CompressionLevel #
Compression level presets that define the tradeoff between computational complexity and compression ratio
CompressionLevel0 has the lowest compression ratio as well as the
lowest memory requirements, whereas CompressionLevel9 has the
highest compression ratio and can require over 600MiB during
compression (and over 60MiB during decompression). The
man-page for xz(1)
contains more detailed information with tables describing the
properties of all compression level presets.
CompressionLevel6 is the default setting in
defaultCompressParams as it provides a good trade-off and
matches the default of the xz(1) tool.
Constructors
| CompressionLevel0 | |
| CompressionLevel1 | |
| CompressionLevel2 | |
| CompressionLevel3 | |
| CompressionLevel4 | |
| CompressionLevel5 | |
| CompressionLevel6 | |
| CompressionLevel7 | |
| CompressionLevel8 | |
| CompressionLevel9 |
Instances
Decompression parameters
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.
Instances
| Eq DecompressParams # | |
Defined in LibLzma Methods (==) :: DecompressParams -> DecompressParams -> Bool # (/=) :: DecompressParams -> DecompressParams -> Bool # | |
| Show DecompressParams # | |
Defined in LibLzma Methods showsPrec :: Int -> DecompressParams -> ShowS # show :: DecompressParams -> String # showList :: [DecompressParams] -> ShowS # | |
decompressTellNoCheck :: DecompressParams -> Bool #
DecompressParams field: If set, abort if decoded stream has no integrity check.
decompressTellUnsupportedCheck :: DecompressParams -> Bool #
DecompressParams field: If set, abort (via LzmaRetGetCheck) if decoded stream integrity check is unsupported.
decompressTellAnyCheck :: DecompressParams -> Bool #
DecompressParams field: If set, abort (via LzmaRetGetCheck) as soon as the type of the integrity check has been detected.
decompressConcatenated :: DecompressParams -> Bool #
DecompressParams field: If set, concatenated files as decoded seamless.
decompressAutoDecoder :: DecompressParams -> Bool #
DecompressParams field: If set, legacy .lzma-encoded streams are allowed too.
decompressMemLimit :: DecompressParams -> Word64 #
DecompressParams field: decompressor memory limit. Set to maxBound to disable memory limit.