zlib-enum-0.2.3.1: Enumerator interface for zlib compression

Safe HaskellNone

Codec.Zlib.Enum

Contents

Synopsis

Enumeratees

compressSource

Arguments

:: MonadIO m 
=> Int

Compression level

-> WindowBits

Zlib parameter (see the zlib-bindings package as well as the zlib C library)

-> Enumeratee ByteString ByteString m a 

Compress (deflate) a stream of ByteStrings. The WindowBits also control the format (zlib vs. gzip).

decompressSource

Arguments

:: MonadIO m 
=> WindowBits

Zlib parameter (see the zlib-bindings package as well as the zlib C library)

-> Enumeratee ByteString ByteString m a 

Decompress (inflate) a stream of ByteStrings. For example:

    run $ enumFile "test.z" $$ decompress defaultWindowBits $$ printChunks True

gzip :: MonadIO m => Enumeratee ByteString ByteString m aSource

Gzip compression with default parameters.

ungzip :: MonadIO m => Enumeratee ByteString ByteString m aSource

Gzip decompression with default parameters.

Re-exported from zlib-bindings

data WindowBits

This specifies the size of the compression window. Larger values of this parameter result in better compression at the expense of higher memory usage.

The compression window size is the value of the the window bits raised to the power 2. The window bits must be in the range 8..15 which corresponds to compression window sizes of 256b to 32Kb. The default is 15 which is also the maximum size.

The total amount of memory used depends on the window bits and the MemoryLevel. See the MemoryLevel for the details.

Constructors

WindowBits Int 

defaultWindowBits :: WindowBits

The default WindowBits is 15 which is also the maximum size.

data ZlibException

Exception that can be thrown from the FFI code. The parameter is the numerical error code from the zlib library. Quoting the zlib.h file directly:

  • #define Z_OK 0
  • #define Z_STREAM_END 1
  • #define Z_NEED_DICT 2
  • #define Z_ERRNO (-1)
  • #define Z_STREAM_ERROR (-2)
  • #define Z_DATA_ERROR (-3)
  • #define Z_MEM_ERROR (-4)
  • #define Z_BUF_ERROR (-5)
  • #define Z_VERSION_ERROR (-6)