zlib-conduit-0.5.0: Streaming compression/decompression via conduits.

Safe HaskellSafe-Infered

Data.Conduit.Zlib

Contents

Description

Streaming compression and decompression using conduits.

Parts of this code were taken from zlib-enum and adapted for conduits.

Synopsis

Conduits

compressSource

Arguments

:: (MonadUnsafeIO m, MonadThrow m) 
=> Int

Compression level

-> WindowBits

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

-> GInfConduit ByteString m ByteString 

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

decompressSource

Arguments

:: (MonadUnsafeIO m, MonadThrow m) 
=> WindowBits

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

-> GInfConduit ByteString m ByteString 

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

    sourceFile "test.z" $= decompress defaultWindowBits $$ sinkFile "test"

gzip :: (MonadThrow m, MonadUnsafeIO m) => GInfConduit ByteString m ByteStringSource

Gzip compression with default parameters.

ungzip :: (MonadUnsafeIO m, MonadThrow m) => GInfConduit ByteString m ByteStringSource

Gzip decompression with default parameters.

Flushing

compressFlushSource

Arguments

:: (MonadUnsafeIO m, MonadThrow m) 
=> Int

Compression level

-> WindowBits

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

-> GInfConduit (Flush ByteString) m (Flush ByteString) 

Same as compress, but allows you to explicitly flush the stream.

decompressFlushSource

Arguments

:: (MonadUnsafeIO m, MonadThrow m) 
=> WindowBits

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

-> GInfConduit (Flush ByteString) m (Flush ByteString) 

Same as decompress, but allows you to explicitly flush the stream.

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.