Module

Protobuf.Common

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

You almost never need to import this module. See package README for explanation.

#FieldNumber Source

#Bytes Source

newtype Bytes

Representation of a bytes Scalar Value Type field.

Constructors

Instances

#fromDefault Source

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

Turns a default value into Nothing.

#toDefault Source

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

Turns Nothing into a default value.

The Protobuf spec requires that a field being set to zero (“default”) and a missing field are equivalent states. Because of this, there is no way to tell whether a missing field from a received message is really missing or if the sender meant that the field value is zero. We can use this function to manually choose whether we want a missing field to mean that it’s missing, or to mean that it’s zero.