Safe Haskell | None |
---|---|
Language | Haskell2010 |
Mid-level FFI bindings in the IO
monad to lzlib.
See also Codec.Compression.Lzlib.ST for the ST
monad version.
Synopsis
- data LzEncoder
- data CompressParams = CompressParams {}
- compressParamPreset :: Int -> CompressParams
- lzCompressOpen :: CompressParams -> IO (Either LzErrno LzEncoder)
- lzCompressClose :: LzEncoder -> IO ()
- lzCompressRead :: LzEncoder -> Int -> IO ByteString
- lzCompressWrite :: LzEncoder -> ByteString -> IO Int
- lzCompressSyncFlush :: LzEncoder -> IO LzErrno
- lzCompressFinish :: LzEncoder -> IO LzErrno
- lzCompressFinished :: LzEncoder -> IO Bool
- lzCompressMemberFinished :: LzEncoder -> IO Bool
- lzCompressRestartMember :: LzEncoder -> Word64 -> IO LzErrno
- data LzDecoder
- lzDecompressOpen :: IO (Either LzErrno LzDecoder)
- lzDecompressClose :: LzDecoder -> IO ()
- lzDecompressRead :: LzDecoder -> Int -> IO ByteString
- lzDecompressWrite :: LzDecoder -> ByteString -> IO Int
- lzDecompressSyncToMember :: LzDecoder -> IO LzErrno
- lzDecompressFinish :: LzDecoder -> IO LzErrno
- lzDecompressFinished :: LzDecoder -> IO Bool
- lzDecompressMemberFinished :: LzDecoder -> IO Bool
- lzDecompressReset :: LzDecoder -> IO LzErrno
- data LzErrno
Compression functions
data CompressParams Source #
Parameters for lzip
compressor
If compressDictionarySize
is 65535 and compressMatchLenLimit
is 16, the "fast variant" of LZMA is chosen.
CompressParams | |
|
compressParamPreset :: Int -> CompressParams Source #
Construct CompressParams
based on the standard preset levels used by the lzip
command-line interface.
The table below shows the parameters as a function of the level input argument:
level | compressDictionarySize | compressMatchLenLimit |
---|---|---|
≤0 | 65535 bytes | 16 bytes |
1 | 1 MiB | 5 bytes |
2 | 1.5 MiB | 6 bytes |
3 | 2 MiB | 8 bytes |
4 | 3 MiB | 12 bytes |
5 | 4 MiB | 20 bytes |
6 | 8 MiB | 36 bytes |
7 | 16 MiB | 68 bytes |
8 | 24 MiB | 132 bytes |
≥9 | 32 MiB | 273 bytes |
compressMemberSize
is set to its maximum allowed value (i.e. 2 PiB) for all compression levels.
NOTE: The "0" preset parameters will cause the encoder to use the "fast variant" of the LZMA algorithm.
lzCompressOpen :: CompressParams -> IO (Either LzErrno LzEncoder) Source #
Construct new LzEncoder
.
If a LzEncoder
was constructed succesfully it will be in the LzOk
state (as reported by lzCompressErrno
).
NOTE: lzCompressClose
will be invoked automatically when LzEncoder
is garbage collected.
lzCompressClose :: LzEncoder -> IO () Source #
Promptly finalize a LzEncoder
.
It is not necessary to invoke lzCompressClose
explicitly as it
will be invoked implicitly when a LzEncoder
is garbage collected.
See also lzCompressOpen
.
lzCompressRead :: LzEncoder -> Int -> IO ByteString Source #
Retrieve up to n bytes of the compressed stream from the encoder.
Returns the empty ByteString
when the output buffer has been drained.
lzCompressWrite :: LzEncoder -> ByteString -> IO Int Source #
Push uncompressed data into the encoder. The return value is the number of bytes actually consumed.
lzCompressSyncFlush :: LzEncoder -> IO LzErrno Source #
Force the encoder to output the compressed stream for all the uncompressed input data.
After this operation, the output buffer has to be drained via repeated invocations of lzCompressRead
.
lzCompressFinish :: LzEncoder -> IO LzErrno Source #
Finalize current member.
After this operation, the output buffer has to be drained via repeated invocations of lzCompressRead
.
See also lzCompressFinished
and lzCompressMemberFinished
.
lzCompressFinished :: LzEncoder -> IO Bool Source #
Returns True
if the output buffer has been drained completely (which implies lzCompressMemberFinished
).
lzCompressMemberFinished :: LzEncoder -> IO Bool Source #
Returns True
if the output buffer has been drained completely and lzCompressRestartMember
can be invoked.
lzCompressRestartMember :: LzEncoder -> Word64 -> IO LzErrno Source #
Start a new member in a multimember compression stream.
Must only be called when lzCompressMemberFinished
is True
.
Decompression functions
lzDecompressOpen :: IO (Either LzErrno LzDecoder) Source #
Construct new LzDecoder
.
If a LzDecoder
was constructed succesfully it will be in the LzOk
state (as reported by lzDecompressErrno
).
NOTE: lzDecompressClose
will be invoked automatically when LzDecoder
is garbage collected.
lzDecompressClose :: LzDecoder -> IO () Source #
Promptly finalize a LzDecoder
.
It is not necessary to invoke lzDecompressClose
explicitly as it
will be invoked implicitly when a LzDecoder
is garbage collected.
See also lzDecompressOpen
.
lzDecompressRead :: LzDecoder -> Int -> IO ByteString Source #
Retrieve up to n bytes of the decompressed stream from the decoder.
Returns the empty ByteString
when the output buffer has been drained.
lzDecompressWrite :: LzDecoder -> ByteString -> IO Int Source #
Push compressed data into the decoder. The return value is the number of bytes actually consumed.
lzDecompressSyncToMember :: LzDecoder -> IO LzErrno Source #
Instruct decoder to discard data of current member and skip till next member.
This is a no-op if the decoder is already at the start of a member.
lzDecompressFinish :: LzDecoder -> IO LzErrno Source #
Finalize current member.
After this operation, the output buffer has to be drained via repeated invocations of lzDecompressRead
.
See also lzDecompressFinished
and lzDecompressMemberFinished
.
lzDecompressFinished :: LzDecoder -> IO Bool Source #
Returns True
if the output buffer has been drained completely (which implies lzDecompressMemberFinished
).
lzDecompressMemberFinished :: LzDecoder -> IO Bool Source #
Returns True
if the output buffer has been drained completely and lzDecompressRestartMember
can be invoked.
lzDecompressReset :: LzDecoder -> IO LzErrno Source #
Reset LzEncoder
into the initial state (as if lzCompressOpen
had just been invoked) and discard all data.
Error codes
lzlib
error codes
See lzlib manual for more details.
LzOk | |
LzBadArgument | |
LzMemError | |
LzSequenceError | |
LzHeaderError | |
LzUnexpectedEof | |
LzDataError | |
LzLibraryError | |
LzUnknown | not defined by |
Instances
Eq LzErrno Source # | |
Show LzErrno Source # | |
Exception LzErrno Source # | |
Defined in Codec.Compression.Lzlib.FFI toException :: LzErrno -> SomeException # fromException :: SomeException -> Maybe LzErrno # displayException :: LzErrno -> String # |