Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell98 |
Data.Conduit.Cereal
Description
Turn a Get
into a Sink
and a PutM
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 -> 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
Exception GetException Source # | |
Defined in Data.Conduit.Cereal Methods toException :: GetException -> SomeException Source # fromException :: SomeException -> Maybe GetException Source # | |
Show GetException Source # | |
Defined in Data.Conduit.Cereal |
sinkGet :: MonadThrow m => Get r -> ConduitT ByteString o 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 -> ConduitT ByteString o m () Source #
Deprecated: Please switch to conduitGet2, see comment on that function
Run a Get
repeatedly on the input stream, producing an output stream of whatever the Get
outputs.
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
ByteString
s, which leads to non-constant memory usage. - This function will properly terminate a
Get
function at end of stream, see https://github.com/snoyberg/conduit/issues/246. conduitGet
will pass emptyByteString
s 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 emptyByteString
s are filtered out and not passed to cereal.- After
conduitGet2
successfully 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 PutM
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.