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

Safe Haskell | None
Language | Haskell98

Data.Conduit.Serialization.Binary

Synopsis

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

# Documentation

conduitDecode :: forall b (m :: Type -> Type). (Binary b, MonadThrow m) => ConduitT ByteString b m () Source #

Runs default `Decoder` repeatedly on a input stream.

conduitEncode :: forall b (m :: Type -> Type). (Binary b, MonadThrow m) => ConduitT b ByteString m () Source #

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 :: forall (m :: Type -> Type) b. (Monad m, Binary b) => ConduitT b ByteString m () Source #

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 :: forall (m :: Type -> Type) b. MonadThrow m => Get b -> ConduitT ByteString b m () Source #

Runs getter repeatedly on a input stream.

conduitPut :: forall (m :: Type -> Type). Monad m => ConduitT Put ByteString m () Source #

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

conduitPutList :: forall (m :: Type -> Type). Monad m => ConduitT Put [ByteString] m () Source #

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

conduitPutLBS :: forall (m :: Type -> Type). Monad m => ConduitT Put ByteString m () Source #

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 :: forall (m :: Type -> Type). Monad m => ConduitT Put (Vector ByteString) m () Source #

Vectorized variant of `conduitPut`.

sourcePut :: forall (m :: Type -> Type) z. Monad m => Put -> ConduitT z ByteString m () Source #

Create stream of strict bytestrings from `Put` value.

sinkGet :: forall (m :: Type -> Type) b z. MonadThrow m => Get b -> ConduitT ByteString z m b Source #

Decode message from input stream.

data ParseError Source #

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

Instances details

Exception ParseError Source # |
Instance details Defined in Data.Conduit.Serialization.Binary Methods toException :: ParseError -> SomeException Source # fromException :: SomeException -> Maybe ParseError Source # displayException :: ParseError -> String Source # backtraceDesired :: ParseError -> Bool Source #
Show ParseError Source # |
Instance details Defined in Data.Conduit.Serialization.Binary Methods showsPrec :: Int -> ParseError -> ShowS Source # show :: ParseError -> String Source # showList :: [ParseError] -> ShowS Source #