Module

Protobuf.Internal.Common

Package
purescript-protobuf
Repository
xc-jp/purescript-protobuf

Common utility definitions.

#Bytes Source

newtype Bytes

Representation of a bytes Scalar Value Type field.

On a message which has been decoded, The wrapped DataBuff will usually be a DataView. In that case, the DataView is a view into the received message I/O buffer.

For messages which you intend to encode, You may set the DataBuff to DataView or ArrayBuffer, whichever seems best.

The ArrayBuffer and DataView are mutable, so be careful not to mutate them if anything might read them again. Here we trade off typechecker guarantees for implementation simplicity.

Constructors

Instances

#FieldNumber Source

#Default Source

class Default a  where

In Protobuf, zero values are “default values” and have special semantics.

Members

Instances

#fromDefault Source

fromDefault :: forall a. Default a => Eq a => a -> Maybe a

Turns a “default” (zero) value into Nothing.

#label Source

label :: forall m s a. Monad m => String -> ParserT s m a -> ParserT s m a

If parsing fails inside this labelled context, then prepend the String to the error String in the ParseError. Use this to establish context for parsing failure error messages.

#toDefault Source

toDefault :: forall a. Default a => Maybe a -> a

Turns Nothing into a “default” (zero) value.

The Protobuf spec requires that a no presence field set to its “default” (zero) value must not be serialized to the wire.

When receiving messages we can use this function to interpret a missing no presence field as a “default” value.