cereal-conduit-0.7.2.3: Turn Data.Serialize Gets and Puts into Sources, Sinks, and Conduits

Safe Haskell | None
Language | Haskell98

Data.Conduit.Cereal

Description

Turn a `Get` into a `Sink` and a `Put` into a `Source` These functions are built upno the Data.Conduit.Cereal.Internal functions with default implementations of `ErrorHandler` and `TerminationHandler`

The default `ErrorHandler` and `TerminationHandler` both throw a `GetException`.

Synopsis

- data GetException
- sinkGet :: MonadThrow m => Get r -> Consumer ByteString m r
- conduitGet :: MonadThrow m => Get o -> Conduit ByteString m o
- sourcePut :: Monad m => Put -> Producer m ByteString
- conduitPut :: Monad m => Putter a -> Conduit a m ByteString

# Documentation

data GetException Source

Instances

Show GetException Source |
Exception GetException Source |

sinkGet :: MonadThrow m => Get r -> Consumer ByteString m r Source

Convert a `Get` into a `Sink`. The `Get` will be streamed bytes until it returns `Done` or `Fail`.

If `Get` succeed it will return the data read and unconsumed part of the input stream. If the `Get` fails due to deserialization error or early termination of the input stream it raise an error.

conduitGet :: MonadThrow m => Get o -> Conduit ByteString m o Source

Run a `Get` repeatedly on the input stream, producing an output stream of whatever the `Get` outputs.

sourcePut :: Monad m => Put -> Producer m ByteString Source

Convert a `Put` into a `Source`. Runs in constant memory.

conduitPut :: Monad m => Putter a -> Conduit a m ByteString Source

Run a `Putter` repeatedly on the input stream, producing a concatenated `ByteString` stream.