typed-protocols-cborg-0.1.0.4: CBOR codecs for typed-protocols
Safe HaskellSafe-Inferred
LanguageHaskell2010

Network.TypedProtocol.Codec.CBOR

Synopsis

Documentation

mkCodecCborLazyBS :: forall ps m. MonadST m => (forall (pr :: PeerRole) (st :: ps) (st' :: ps). PeerHasAgency pr st -> Message ps st st' -> Encoding) -> (forall (pr :: PeerRole) (st :: ps) s. PeerHasAgency pr st -> Decoder s (SomeMessage st)) -> Codec ps DeserialiseFailure m ByteString Source #

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 :: forall ps m. MonadST m => (forall (pr :: PeerRole) (st :: ps) (st' :: ps). PeerHasAgency pr st -> Message ps st st' -> Encoding) -> (forall (pr :: PeerRole) (st :: ps) s. PeerHasAgency pr st -> Decoder s (SomeMessage st)) -> Codec ps DeserialiseFailure m ByteString Source #

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).