Safe Haskell | None |
---|
This module exports facilities that allows you to encode and decode
streams of Binary
values using the pipes
and pipes-parse
libraries.
- decode :: (Proxy p, Monad m, Binary r) => EitherP DecodingError (StateP [ByteString] p) () (Maybe ByteString) y' y m r
- decodeD :: (Proxy p, Monad m, Binary b) => () -> Pipe (EitherP DecodingError (StateP [ByteString] p)) (Maybe ByteString) b m ()
- encode :: (Proxy p, Monad m, Binary x) => x -> p x' x () ByteString m ()
- encodeD :: (Proxy p, Monad m, Binary a) => () -> Pipe p a ByteString m r
- data DecodingError = DecodingError {}
Decoding
There are two different Binary
decoding facilities exported by this
module, and choosing between them is easy: If you need to interleave decoding
with other stream effects you must use decode
, otherwise you may use the
simpler decodeD
.
decode :: (Proxy p, Monad m, Binary r) => EitherP DecodingError (StateP [ByteString] p) () (Maybe ByteString) y' y m rSource
Decodes one Binary
instance flowing downstream.
- In case of decoding errors, a
DecodingError
exception is thrown in theEitherP
proxy transformer. - Requests more input from upstream using
draw
when needed. - Do not use this proxy if
isEndOfBytes
returnsTrue
, otherwise you may get unexpected decoding errors.
decodeD :: (Proxy p, Monad m, Binary b) => () -> Pipe (EitherP DecodingError (StateP [ByteString] p)) (Maybe ByteString) b m ()Source
Decodes Binary
instances flowing downstream until end of input.
- In case of decoding errors, a
DecodingError
exception is thrown in theEitherP
proxy transformer. - Requests more input from upstream using
draw
, when needed. - Empty input chunks flowing downstream will be discarded.
Encoding
There are two different Binary
encoding facilities exported by this
module, and choosing between them is easy: If you need to interleave encoding
with other stream effects you must use encode
, otherwise you may use the
simpler encodeD
.
encode :: (Proxy p, Monad m, Binary x) => x -> p x' x () ByteString m ()Source
Encodes the given Binary
instance and sends it downstream in
ByteString
chunks.
encodeD :: (Proxy p, Monad m, Binary a) => () -> Pipe p a ByteString m rSource
Encodes Binary
instances flowing downstream, each in possibly more
than one ByteString
chunk.
Types
data DecodingError Source
DecodingError | |
|