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

Safe Haskell | None

Data.Conduit.Zlib

Contents

- Conduits
- Flushing
- Re-exported from zlib-bindings

Description

Streaming compression and decompression using conduits.

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

Synopsis

- compress :: (MonadUnsafeIO m, MonadThrow m) => Int -> WindowBits -> Conduit ByteString m ByteString
- decompress :: (MonadUnsafeIO m, MonadThrow m) => WindowBits -> Conduit ByteString m ByteString
- gzip :: (MonadThrow m, MonadUnsafeIO m) => Conduit ByteString m ByteString
- ungzip :: (MonadUnsafeIO m, MonadThrow m) => Conduit ByteString m ByteString
- compressFlush :: (MonadUnsafeIO m, MonadThrow m) => Int -> WindowBits -> Conduit (Flush ByteString) m (Flush ByteString)
- decompressFlush :: (MonadUnsafeIO m, MonadThrow m) => WindowBits -> Conduit (Flush ByteString) m (Flush ByteString)
- data WindowBits = WindowBits Int
- defaultWindowBits :: WindowBits

# Conduits

compress Source

Arguments

:: (MonadUnsafeIO m, MonadThrow m) |
=> Int | Compression level
-> WindowBits | Zlib parameter (see the zlib-bindings package as well as the zlib C library)
-> Conduit ByteString m ByteString |

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

decompress Source

Arguments

:: (MonadUnsafeIO m, MonadThrow m) |
=> WindowBits | Zlib parameter (see the zlib-bindings package as well as the zlib C library)
-> Conduit ByteString m ByteString |

Decompress (inflate) a stream of `ByteString`s. For example:

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

gzip :: (MonadThrow m, MonadUnsafeIO m) => Conduit ByteString m ByteString Source

Gzip compression with default parameters.

ungzip :: (MonadUnsafeIO m, MonadThrow m) => Conduit ByteString m ByteString Source

Gzip decompression with default parameters.

# Flushing

compressFlush Source

Arguments

:: (MonadUnsafeIO m, MonadThrow m) |
=> Int | Compression level
-> WindowBits | Zlib parameter (see the zlib-bindings package as well as the zlib C library)
-> Conduit (Flush ByteString) m (Flush ByteString) |

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

decompressFlush Source

Arguments

:: (MonadUnsafeIO m, MonadThrow m) |
=> WindowBits | Zlib parameter (see the zlib-bindings package as well as the zlib C library)
-> Conduit (Flush ByteString) m (Flush ByteString) |

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

# Re-exported from zlib-bindings

data WindowBits

Constructors

WindowBits Int |

defaultWindowBits :: WindowBits