| 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.
- data GetException
- sinkGet :: MonadThrow m => Get r -> ConduitT ByteString o m r
- conduitGet :: MonadThrow m => Get o -> ConduitT ByteString o m ()
- conduitGet2 :: MonadThrow m => Get o -> ConduitT ByteString o m ()
- sourcePut :: Monad m => Put -> ConduitT i ByteString m ()
- conduitPut :: Monad m => Putter a -> ConduitT a ByteString m ()
Documentation
data GetException Source #
Instances
sinkGet :: MonadThrow m => Get r -> ConduitT ByteString o m r Source #
conduitGet :: MonadThrow m => Get o -> ConduitT ByteString o m () Source #
conduitGet2 :: MonadThrow m => Get o -> ConduitT ByteString o m () Source #
Reapply Get o to a stream of bytes as long as more data is available,
and yielding each new value downstream. This has a few differences from
conduitGet:
- If there is a parse failure, the bytes consumed so far by this will not be
returned as leftovers. The reason for this is that the only way to guarantee
the leftovers will be returned correctly is to hold onto all consumed
ByteStrings, which leads to non-constant memory usage. - This function will properly terminate a
Getfunction at end of stream, see https://github.com/snoyberg/conduit/issues/246. conduitGetwill pass emptyByteStrings from the stream directly to cereal, which will trigger cereal to think that the stream has been closed. This breaks the normal abstraction in conduit of ignoring how data is chunked. InconduitGet2, all emptyByteStrings are filtered out and not passed to cereal.- After
conduitGet2successfully returns, we are guaranteed that there is no data left to be consumed in the stream.
Since: 0.7.3
sourcePut :: Monad m => Put -> ConduitT i ByteString m () Source #
Convert a Put into a Source. Runs in constant memory.
conduitPut :: Monad m => Putter a -> ConduitT a ByteString m () Source #
Run a Putter repeatedly on the input stream, producing a concatenated ByteString stream.