proto-lens-0.4.0.0: A lens-based implementation of protocol buffers in Haskell.

Safe HaskellNone
LanguageHaskell2010

Data.ProtoLens.Encoding

Description

Functions for encoding and decoding protocol buffer Messages.

TODO: Currently all operations are on strict ByteStrings; we should try to generalize to lazy Bytestrings as well.

Synopsis

Documentation

encodeMessage :: Message msg => msg -> ByteString Source #

Encode a message to the wire format as a strict ByteString.

buildMessage :: Message msg => msg -> Builder Source #

Encode a message to the wire format, as part of a Builder.

buildMessageDelimited :: Message msg => msg -> Builder Source #

Encode a message to the wire format, prefixed by its size as a VarInt, as part of a Builder.

This can be used to build up streams of messages in the size-delimited format expected by some protocols.

decodeMessage :: Message msg => ByteString -> Either String msg Source #

Decode a message from its wire format. Returns Left if the decoding fails.

decodeMessageOrDie :: Message msg => ByteString -> msg Source #

Decode a message from its wire format. Throws an error if the decoding fails.