typed-protocols-stateful-cborg
Safe HaskellNone
LanguageHaskell2010

Network.TypedProtocol.Stateful.Codec.CBOR

Synopsis

Documentation

data DeserialiseFailure #

An exception type that may be returned (by pure functions) or thrown (by IO actions) that fail to deserialise a given input.

Since: cborg-0.2.0.0

mkCodecCborLazyBS Source #

Arguments

:: forall ps f (m :: Type -> Type). MonadST m 
=> (forall (st :: ps) (st' :: ps). (StateTokenI st, ActiveState st) => f st -> Message ps st st' -> Encoding)

cbor encoder

-> (forall (st :: ps) s. ActiveState st => StateToken st -> f st -> Decoder s (SomeMessage st))

cbor decoder

-> Codec ps DeserialiseFailure f m ByteString 

Construct a Codec for a CBOR based serialisation format, using lazy ByteStrings.

This is an adaptor between the cborg library and the Codec abstraction.

It takes encode and decode functions for the protocol messages that use the CBOR library encoder and decoder.

mkCodecCborStrictBS Source #

Arguments

:: forall ps f (m :: Type -> Type). MonadST m 
=> (forall (st :: ps) (st' :: ps). (StateTokenI st, ActiveState st) => f st -> Message ps st st' -> Encoding)

cbor encoder

-> (forall (st :: ps) s. ActiveState st => StateToken st -> f st -> Decoder s (SomeMessage st))

cbor decoder

-> Codec ps DeserialiseFailure f m ByteString 

Construct a Codec for a CBOR based serialisation format, using strict ByteStrings.

This is an adaptor between the cborg library and the Codec abstraction.

It takes encode and decode functions for the protocol messages that use the CBOR library encoder and decoder.

Note that this is less efficient than the mkCodecCborLazyBS variant because it has to copy and concatenate the result of the encoder (which natively produces chunks).