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


-- | Streaming interface to binary.
--   
--   Streaming interface to binary.
@package streaming-binary
@version 0.3.0.1


-- | This module implements a method to ingest a sequence of
--   <a>Data.Binary</a> encoded records using bounded memory. Minimal
--   example:
--   
--   <pre>
--   {-# LANGUAGE TypeApplications #-}
--   
--   import Data.Function ((&amp;))
--   import qualified Data.ByteString.Streaming as Q
--   import Streaming
--   import Streaming.Binary
--   import qualified Streaming.Prelude as S
--   
--   -- Interpret all bytes on stdin as a sequence of integers.
--   -- Print them on-the-fly on stdout.
--   main = Q.getContents &amp; decoded @Int &amp; S.print
--   </pre>
module Streaming.Binary

-- | Decode a single element from a streaming bytestring. Returns any
--   leftover input, the number of bytes consumed, and either an error
--   string or the element if decoding succeeded.
decode :: (Binary a, Monad m) => ByteString m r -> m (ByteString m r, Int64, Either String a)

-- | Like <a>decode</a>, but with an explicitly provided decoder.
decodeWith :: Monad m => Get a -> ByteString m r -> m (ByteString m r, Int64, Either String a)

-- | Decode a sequence of elements from a streaming bytestring. Returns any
--   leftover input, the number of bytes consumed, and either an error
--   string or the return value if there were no errors. Decoding stops at
--   the first error.
decoded :: (Binary a, Monad m) => ByteString m r -> Stream (Of a) m (ByteString m r, Int64, Either String r)

-- | Like <a>decoded</a>, but with an explicitly provided decoder.
decodedWith :: Monad m => Get a -> ByteString m r -> Stream (Of a) m (ByteString m r, Int64, Either String r)

-- | Encode a single element.
encode :: (Binary a, MonadIO m) => a -> ByteString m ()

-- | Like <a>encode</a>, but with an explicitly provided encoder.
encodeWith :: MonadIO m => (a -> Put) -> a -> ByteString m ()

-- | Encode a stream of elements to a streaming bytestring.
encoded :: (Binary a, MonadIO m) => Stream (Of a) IO () -> ByteString m ()

-- | Like <a>encoded</a>, but with an explicitly provided encoder.
encodedWith :: MonadIO m => (a -> Put) -> Stream (Of a) IO () -> ByteString m ()
