-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/

-- | Turn Data.Serialize Gets and Puts into Sources, Sinks, and Conduits
--   
--   Turn Data.Serialize Gets and Puts into Sources, Sinks, and Conduits.
--   
--   
--   
- 0.7 Upgrade to conduit 1.0.0
--   
@package cereal-conduit
@version 0.7.2.3

module Data.Conduit.Cereal.Internal

-- | What should we do if the Get fails?
type ConduitErrorHandler m o = String -> Conduit ByteString m o
type SinkErrorHandler m r = String -> Consumer ByteString m r

-- | What should we do if the stream is done before the Get is done?
type SinkTerminationHandler m r = (ByteString -> Result r) -> Consumer ByteString m r

-- | Construct a conduitGet with the specified ErrorHandler
mkConduitGet :: Monad m => ConduitErrorHandler m o -> Get o -> Conduit ByteString m o

-- | Construct a sinkGet with the specified ErrorHandler and
--   TerminationHandler
mkSinkGet :: Monad m => SinkErrorHandler m r -> SinkTerminationHandler m r -> Get r -> Consumer ByteString m r

-- | 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.
module Data.Conduit.Cereal
data GetException

-- | 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.
sinkGet :: MonadThrow m => Get r -> Consumer ByteString m r

-- | Run a Get repeatedly on the input stream, producing an output
--   stream of whatever the Get outputs.
conduitGet :: MonadThrow m => Get o -> Conduit ByteString m o

-- | Convert a Put into a Source. Runs in constant memory.
sourcePut :: Monad m => Put -> Producer m ByteString

-- | Run a Putter repeatedly on the input stream, producing a
--   concatenated ByteString stream.
conduitPut :: Monad m => Putter a -> Conduit a m ByteString
instance GHC.Show.Show Data.Conduit.Cereal.GetException
instance GHC.Exception.Exception Data.Conduit.Cereal.GetException
