binary-conduit-1.2.4.1: data serialization/deserialization conduit library

Safe Haskell | None
Language | Haskell98

Data.Conduit.Serialization.Binary

Synopsis

- conduitDecode :: (Binary b, MonadThrow m) => Conduit ByteString m b
- conduitEncode :: (Binary b, MonadThrow m) => Conduit b m ByteString
- conduitMsgEncode :: (Binary b, MonadThrow m) => Conduit b m ByteString
- conduitGet :: MonadThrow m => Get b -> Conduit ByteString m b
- conduitPut :: MonadThrow m => Conduit Put m ByteString
- conduitPutList :: MonadThrow m => Conduit Put m [ByteString]
- conduitPutLBS :: MonadThrow m => Conduit Put m ByteString
- conduitPutMany :: MonadThrow m => Conduit Put m (Vector ByteString)
- sourcePut :: MonadThrow m => Put -> Producer m ByteString
- sinkGet :: MonadThrow m => Get b -> Consumer ByteString m b
- data ParseError = ParseError {
  - unconsumed :: ByteString
  - offset :: ByteOffset
  - content :: String
  }

# Documentation

conduitDecode :: (Binary b, MonadThrow m) => Conduit ByteString m b #

Runs default `Decoder` repeatedly on a input stream.

conduitEncode :: (Binary b, MonadThrow m) => Conduit b m ByteString #

Runs default encoder on a input stream.

This function produces a stream of bytes where for each input value you will have a number of `ByteString`s, and no boundary between different values.

conduitMsgEncode :: (Binary b, MonadThrow m) => Conduit b m ByteString #

Runs default encoder on input stream.

This function produces a ByteString per each incomming packet, it may be useful in datagram based protocols. Function maintains following property

      'conduitMsgEncode' xs == 'CL.map' 'Data.ByteString.encode' =$= 'CL.map' 'LBS.toStrict'

This invariant is maintaind by the cost of additional data copy, so if you packets can be serialized to the large data chunks or you interested in iterative packet serialization concider using `conduitPutList` or `conduitPutMany`

conduitGet :: MonadThrow m => Get b -> Conduit ByteString m b #

Runs getter repeatedly on a input stream.

conduitPut :: MonadThrow m => Conduit Put m ByteString #

Runs putter repeatedly on a input stream, returns an output stream.

conduitPutList :: MonadThrow m => Conduit Put m [ByteString] #

Vectorized variant of `conduitPut` returning list contains all chunks from one element representation

conduitPutLBS :: MonadThrow m => Conduit Put m ByteString #

Runs putter repeatedly on a input stream. Returns a lazy butestring so it's possible to use vectorized IO on the result either by calling' LBS.toChunks' or by calling `send`.

conduitPutMany :: MonadThrow m => Conduit Put m (Vector ByteString) #

Vectorized variant of `conduitPut`.

sourcePut :: MonadThrow m => Put -> Producer m ByteString #

Create stream of strict bytestrings from `Put` value.

sinkGet :: MonadThrow m => Get b -> Consumer ByteString m b #

Decode message from input stream.

data ParseError #

Constructors

ParseError |
Fields unconsumed :: ByteString Data left unconsumed in single stream input value. offset :: ByteOffset Number of bytes consumed from single stream input value. content :: String Error content.

Instances

Show ParseError # |
Methods showsPrec :: Int -> ParseError -> ShowS # show :: ParseError -> String # showList :: [ParseError] -> ShowS #
Exception ParseError # |
Methods toException :: ParseError -> SomeException # fromException :: SomeException -> Maybe ParseError # displayException :: ParseError -> String #