-- 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 -- Data.Binary encoded records using bounded memory. Minimal -- example: -- --
--   {-# LANGUAGE TypeApplications #-}
--   
--   import Data.Function ((&))
--   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 & decoded @Int & S.print
--   
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 decode, 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 decoded, 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 encode, 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 encoded, but with an explicitly provided encoder. encodedWith :: MonadIO m => (a -> Put) -> Stream (Of a) IO () -> ByteString m ()