packages feed

protobuf-simple-0.1.0.0: test/Types/Message.hs

-- Generated by protobuf-simple. DO NOT EDIT!
module Types.Message where

import Control.Applicative ((<$>))
import Prelude ()
import qualified Data.ProtoBufInt as PB
import qualified Types.Int32Msg

data Message = Message
  { bool :: !PB.Bool
  , bytes :: !(PB.Maybe PB.ByteString)
  , int32msgs :: !(PB.Seq Types.Int32Msg.Int32Msg)
  } deriving (PB.Show, PB.Eq, PB.Ord)

instance PB.Default Message where
  defaultVal = Message
    { bool = PB.defaultVal
    , bytes = PB.defaultVal
    , int32msgs = PB.defaultVal
    }

instance PB.Mergeable Message where
  merge a b = Message
    { bool = PB.merge (bool a) (bool b)
    , bytes = PB.merge (bytes a) (bytes b)
    , int32msgs = PB.merge (int32msgs a) (int32msgs b)
    }

instance PB.Required Message where
  reqTags _ = PB.fromList [PB.WireTag 1 PB.VarInt]

instance PB.WireMessage Message where
  fieldToValue (PB.WireTag 1 PB.VarInt) self = (\v -> self{bool = PB.merge (bool self) v}) <$> PB.getBool
  fieldToValue (PB.WireTag 2 PB.LenDelim) self = (\v -> self{bytes = PB.merge (bytes self) v}) <$> PB.getBytesOpt
  fieldToValue (PB.WireTag 3 PB.LenDelim) self = (\v -> self{int32msgs = PB.append (int32msgs self) v}) <$> PB.getMessage
  fieldToValue tag self = PB.getUnknown tag self

  messageToFields self = do
    PB.putBool (PB.WireTag 1 PB.VarInt) (bool self)
    PB.putBytesOpt (PB.WireTag 2 PB.LenDelim) (bytes self)
    PB.putMessageList (PB.WireTag 3 PB.LenDelim) (int32msgs self)