packages feed

wireform-proto-0.1.0.0: bench/compare/gen-wireform/Proto/Bench/Wireform/Messages.hs

{-# LANGUAGE StrictData #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE OverloadedRecordDot #-}
-- | Auto-generated protobuf types from package @bench@.
--
-- __THIS FILE IS AUTO-GENERATED BY wireform. DO NOT EDIT.__
--
-- Any manual changes will be overwritten the next time code
-- generation is run.  To modify the types or instances, edit the
-- @.proto@ source file and re-run the code generator.
module Proto.Bench.Wireform.Messages where

import Data.ByteString (ByteString)
import qualified Data.ByteString as BS
import qualified Wireform.Builder as B
import Data.Int (Int32, Int64)
import Data.Text (Text)
import qualified Data.Text as T
import Data.Word (Word8, Word32, Word64)
import qualified Data.IntMap.Strict as IntMap
import qualified Data.Map.Strict as Map
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import GHC.Generics (Generic)
import Control.DeepSeq (NFData(..))
import Data.Hashable (Hashable(..))
import Proto
import Proto
import Proto.Internal.GrowList (GrowList, emptyGrowList, snocGrowList, growListToVector)
import qualified Data.Aeson as Aeson
import qualified Data.Aeson.Types as Aeson
import qualified Data.Aeson.Key as AesonKey
import qualified Data.Aeson.KeyMap as AesonKM
import Proto.Internal.JSON (jsonObject, (.=:), parseFieldMaybe, bytesFieldToJSON, parseBytesFieldMaybe, bytesMapFieldToJSON, parseBytesMapFieldMaybe, protoBytesToJSON, OneofVariantNullSemantics (..), parseOneofVariants)
import Data.Proxy (Proxy(..))
import Proto.Schema (ProtoMessage(..), SomeFieldDescriptor(..), FieldDescriptor(..), FieldTypeDescriptor(..), ScalarFieldType(..), FieldLabel'(..))
import Proto.Registry (IsMessage)
import Proto.Registry qualified
import qualified Proto.Extension
import Proto.Internal.Wire (Tag(..), WireType(..))
import Proto.Internal.Wire.Encode (putTag, putVarint, putFixed32, putFixed64,
  putFloat, putDouble, putText, putByteString, putLengthDelimited,
  putSVarint32, putSVarint64, putVarintSigned,
  varintSize, tagSize,
  varintSize32, zigZag32, zigZag64)
import Proto.Internal.Encode.Archetype (archVarint, archSVarint32, archSVarint64,
  archFixed32, archFixed64, archFloat, archDouble, archBool,
  archString, archBytes, archSubmessage)

-- | Serialized FileDescriptorProto for this .proto file.
-- Decode with @Proto.Decode.decodeMessage@.
fileDescriptorProtoBytes :: ByteString
fileDescriptorProtoBytes = "\x0a\x0e\x4d\x65\x73\x73\x61\x67\x65\x73\x2e\x70\x72\x6f\x74\x6f\x12\x05\x62\x65\x6e\x63\x68\x22\x31\x0a\x05\x53\x6d\x61\x6c\x6c\x12\x0a\x0a\x02\x69\x64\x18\x01\x20\x00\x28\x02\x12\x0c\x0a\x04\x6e\x61\x6d\x65\x18\x02\x20\x00\x28\x08\x12\x0e\x0a\x06\x61\x63\x74\x69\x76\x65\x18\x03\x20\x00\x28\x07\x22\x8e\x01\x0a\x06\x4d\x65\x64\x69\x75\x6d\x12\x0d\x0a\x05\x74\x69\x74\x6c\x65\x18\x01\x20\x00\x28\x08\x12\x0d\x0a\x05\x63\x6f\x75\x6e\x74\x18\x02\x20\x00\x28\x04\x12\x0d\x0a\x05\x73\x63\x6f\x72\x65\x18\x03\x20\x00\x28\x00\x12\x0f\x0a\x07\x70\x61\x79\x6c\x6f\x61\x64\x18\x04\x20\x00\x28\x0b\x12\x0f\x0a\x07\x65\x6e\x61\x62\x6c\x65\x64\x18\x05\x20\x00\x28\x07\x12\x11\x0a\x09\x74\x69\x6d\x65\x73\x74\x61\x6d\x70\x18\x06\x20\x00\x28\x02\x12\x13\x0a\x0b\x64\x65\x73\x63\x72\x69\x70\x74\x69\x6f\x6e\x18\x07\x20\x00\x28\x08\x12\x0d\x0a\x05\x72\x61\x74\x69\x6f\x18\x08\x20\x00\x28\x01\x22\x3d\x0a\x0a\x57\x69\x74\x68\x4e\x65\x73\x74\x65\x64\x12\x0a\x0a\x02\x69\x64\x18\x01\x20\x00\x28\x02\x12\x14\x0a\x05\x69\x6e\x6e\x65\x72\x18\x02\x20\x00\x28\x0a\x32\x05\x53\x6d\x61\x6c\x6c\x12\x0d\x0a\x05\x6c\x61\x62\x65\x6c\x18\x03\x20\x00\x28\x08\x22\x42\x0a\x0c\x57\x69\x74\x68\x52\x65\x70\x65\x61\x74\x65\x64\x12\x0e\x0a\x06\x76\x61\x6c\x75\x65\x73\x18\x01\x20\x01\x28\x04\x12\x0c\x0a\x04\x74\x61\x67\x73\x18\x02\x20\x01\x28\x08\x12\x14\x0a\x05\x69\x74\x65\x6d\x73\x18\x03\x20\x01\x28\x0a\x32\x05\x53\x6d\x61\x6c\x6c\x62\x06\x70\x72\x6f\x74\x6f\x33"


data Small = Small
  { smallId :: {-# UNPACK #-} !Int64
  , smallName :: !Text
  , smallActive :: {-# UNPACK #-} !Bool
  , smallUnknownFields :: ![UnknownField]
  }
  deriving stock (Show, Eq, Generic)
  deriving anyclass NFData

defaultSmall :: Small
defaultSmall = Small
  { smallId = 0
  , smallName = ""
  , smallActive = False
  , smallUnknownFields = []
  }

instance MessageEncode Small where
  buildSized msg =
    (if msg.smallId == 0 then mempty else archVarint 8 (fromIntegral msg.smallId))
    <> (if msg.smallName == T.empty then mempty else archString 18 msg.smallName)
    <> (if msg.smallActive == False then mempty else archBool 24 msg.smallActive)
    <> encodeUnknownFieldsSized msg.smallUnknownFields

instance MessageDecode Small where
  {-# INLINE messageDecoder #-}
  messageDecoder = stage_0 defaultSmall
    where
      stage_0 msg =
        inOrderStage1
          (0x8 :: Data.Word.Word8)
          (fromIntegral <$> decodeFieldVarint)
          (\v -> stage_1 (msg { smallId = v}))
          (pure (case msg.smallUnknownFields of { [] -> msg; _ -> msg { smallUnknownFields = reverse (msg.smallUnknownFields) } }))
          (loop msg)
      stage_1 msg =
        inOrderStage1
          (0x12 :: Data.Word.Word8)
          decodeFieldString
          (\v -> stage_2 (msg { smallName = v}))
          (pure (case msg.smallUnknownFields of { [] -> msg; _ -> msg { smallUnknownFields = reverse (msg.smallUnknownFields) } }))
          (loop msg)
      stage_2 msg =
        inOrderStage1
          (0x18 :: Data.Word.Word8)
          decodeFieldBool
          (\v -> loop (msg { smallActive = v}))
          (pure (case msg.smallUnknownFields of { [] -> msg; _ -> msg { smallUnknownFields = reverse (msg.smallUnknownFields) } }))
          (loop msg)
      loop msg = withTagM
        (pure (case msg.smallUnknownFields of { [] -> msg; _ -> msg { smallUnknownFields = reverse (msg.smallUnknownFields) } }))
        (\fn wt -> case fn of
          1 -> do
            v <- (fromIntegral <$> decodeFieldVarint)
            loop (msg { smallId = v})
          2 -> do
            v <- decodeFieldString
            loop (msg { smallName = v})
          3 -> do
            v <- decodeFieldBool
            loop (msg { smallActive = v})
          _ -> do
            uf <- captureUnknownField fn (toEnum wt)
            loop (msg { smallUnknownFields = (uf : msg.smallUnknownFields)}))

-- | Field descriptors for 'Small', keyed by proto field number.
--
-- Top-level CAF: allocated lazily on first force, shared on every
-- subsequent 'protoFieldDescriptors' call (no per-call rebuild).
smallFieldDescriptors :: IntMap.IntMap (SomeFieldDescriptor Small)
smallFieldDescriptors =
  IntMap.fromList
    [ (1, SomeField FieldDescriptor
        { fdName = "id"
        , fdNumber = 1
        , fdTypeDesc = ScalarType Int64Field
        , fdLabel = LabelOptional
        , fdGet = smallId
        , fdSet = \v m -> m { smallId = v }
        }), (2, SomeField FieldDescriptor
        { fdName = "name"
        , fdNumber = 2
        , fdTypeDesc = ScalarType StringField
        , fdLabel = LabelOptional
        , fdGet = smallName
        , fdSet = \v m -> m { smallName = v }
        })
    , (3, SomeField FieldDescriptor
        { fdName = "active"
        , fdNumber = 3
        , fdTypeDesc = ScalarType BoolField
        , fdLabel = LabelOptional
        , fdGet = smallActive
        , fdSet = \v m -> m { smallActive = v }
        })
    ]

instance ProtoMessage Small where
  protoMessageName _ = "bench.Small"
  protoPackageName _ = "bench"
  protoDefaultValue = defaultSmall
  protoFileDescriptorBytes _ = fileDescriptorProtoBytes
  protoFieldDescriptors _ = smallFieldDescriptors

instance IsMessage Small

instance Aeson.ToJSON Small where
  toJSON msg = jsonObject
      [ "id" .=: msg.smallId
      , "name" .=: msg.smallName
      , "active" .=: msg.smallActive
      ]

instance Aeson.FromJSON Small where
  parseJSON = Aeson.withObject "Small" $ \obj -> do
    fld_smallId <- parseFieldMaybe obj "id"
    fld_smallName <- parseFieldMaybe obj "name"
    fld_smallActive <- parseFieldMaybe obj "active"
    pure defaultSmall
      { smallId = maybe (smallId defaultSmall) id fld_smallId
      , smallName = maybe (smallName defaultSmall) id fld_smallName
      , smallActive = maybe (smallActive defaultSmall) id fld_smallActive
      }

instance Hashable Small where
  hashWithSalt salt msg = hashWithSalt (hashWithSalt (hashWithSalt (salt) msg.smallId) msg.smallName) msg.smallActive

instance Proto.Extension.HasExtensions Small where
  messageUnknownFields = smallUnknownFields
  setMessageUnknownFields !ufs msg = msg { smallUnknownFields = ufs }

instance Semigroup Small where
  a <> b = Small
    { smallId = if b.smallId == 0 then a.smallId else b.smallId
    , smallName = if b.smallName == "" then a.smallName else b.smallName
    , smallActive = if b.smallActive == False then a.smallActive else b.smallActive
    , smallUnknownFields = a.smallUnknownFields <> b.smallUnknownFields
    }

instance Monoid Small where
  mempty = defaultSmall

data Medium = Medium
  { mediumTitle :: !Text
  , mediumCount :: {-# UNPACK #-} !Int32
  , mediumScore :: {-# UNPACK #-} !Double
  , mediumPayload :: !ByteString
  , mediumEnabled :: {-# UNPACK #-} !Bool
  , mediumTimestamp :: {-# UNPACK #-} !Int64
  , mediumDescription :: !Text
  , mediumRatio :: {-# UNPACK #-} !Float
  , mediumUnknownFields :: ![UnknownField]
  }
  deriving stock (Show, Eq, Generic)
  deriving anyclass NFData

defaultMedium :: Medium
defaultMedium = Medium
  { mediumTitle = ""
  , mediumCount = 0
  , mediumScore = 0
  , mediumPayload = ""
  , mediumEnabled = False
  , mediumTimestamp = 0
  , mediumDescription = ""
  , mediumRatio = 0
  , mediumUnknownFields = []
  }

instance MessageEncode Medium where
  buildSized msg =
    (if msg.mediumTitle == T.empty then mempty else archString 10 msg.mediumTitle)
    <> (if msg.mediumCount == 0 then mempty else archVarint 16 (fromIntegral msg.mediumCount))
    <> (if msg.mediumScore == 0 then mempty else archDouble 25 msg.mediumScore)
    <> (if BS.null msg.mediumPayload then mempty else archBytes 34 msg.mediumPayload)
    <> (if msg.mediumEnabled == False then mempty else archBool 40 msg.mediumEnabled)
    <> (if msg.mediumTimestamp == 0 then mempty else archVarint 48 (fromIntegral msg.mediumTimestamp))
    <> (if msg.mediumDescription == T.empty then mempty else archString 58 msg.mediumDescription)
    <> (if msg.mediumRatio == 0 then mempty else archFloat 69 msg.mediumRatio)
    <> encodeUnknownFieldsSized msg.mediumUnknownFields

instance MessageDecode Medium where
  {-# INLINE messageDecoder #-}
  messageDecoder = stage_0 defaultMedium
    where
      stage_0 msg =
        inOrderStage1
          (0xa :: Data.Word.Word8)
          decodeFieldString
          (\v -> stage_1 (msg { mediumTitle = v}))
          (pure (case msg.mediumUnknownFields of { [] -> msg; _ -> msg { mediumUnknownFields = reverse (msg.mediumUnknownFields) } }))
          (loop msg)
      stage_1 msg =
        inOrderStage1
          (0x10 :: Data.Word.Word8)
          (fromIntegral <$> decodeFieldVarint)
          (\v -> stage_2 (msg { mediumCount = v}))
          (pure (case msg.mediumUnknownFields of { [] -> msg; _ -> msg { mediumUnknownFields = reverse (msg.mediumUnknownFields) } }))
          (loop msg)
      stage_2 msg =
        inOrderStage1
          (0x19 :: Data.Word.Word8)
          decodeFieldDouble
          (\v -> stage_3 (msg { mediumScore = v}))
          (pure (case msg.mediumUnknownFields of { [] -> msg; _ -> msg { mediumUnknownFields = reverse (msg.mediumUnknownFields) } }))
          (loop msg)
      stage_3 msg =
        inOrderStage1
          (0x22 :: Data.Word.Word8)
          decodeFieldBytes
          (\v -> stage_4 (msg { mediumPayload = v}))
          (pure (case msg.mediumUnknownFields of { [] -> msg; _ -> msg { mediumUnknownFields = reverse (msg.mediumUnknownFields) } }))
          (loop msg)
      stage_4 msg =
        inOrderStage1
          (0x28 :: Data.Word.Word8)
          decodeFieldBool
          (\v -> stage_5 (msg { mediumEnabled = v}))
          (pure (case msg.mediumUnknownFields of { [] -> msg; _ -> msg { mediumUnknownFields = reverse (msg.mediumUnknownFields) } }))
          (loop msg)
      stage_5 msg =
        inOrderStage1
          (0x30 :: Data.Word.Word8)
          (fromIntegral <$> decodeFieldVarint)
          (\v -> stage_6 (msg { mediumTimestamp = v}))
          (pure (case msg.mediumUnknownFields of { [] -> msg; _ -> msg { mediumUnknownFields = reverse (msg.mediumUnknownFields) } }))
          (loop msg)
      stage_6 msg =
        inOrderStage1
          (0x3a :: Data.Word.Word8)
          decodeFieldString
          (\v -> stage_7 (msg { mediumDescription = v}))
          (pure (case msg.mediumUnknownFields of { [] -> msg; _ -> msg { mediumUnknownFields = reverse (msg.mediumUnknownFields) } }))
          (loop msg)
      stage_7 msg =
        inOrderStage1
          (0x45 :: Data.Word.Word8)
          decodeFieldFloat
          (\v -> loop (msg { mediumRatio = v}))
          (pure (case msg.mediumUnknownFields of { [] -> msg; _ -> msg { mediumUnknownFields = reverse (msg.mediumUnknownFields) } }))
          (loop msg)
      loop msg = withTagM
        (pure (case msg.mediumUnknownFields of { [] -> msg; _ -> msg { mediumUnknownFields = reverse (msg.mediumUnknownFields) } }))
        (\fn wt -> case fn of
          1 -> do
            v <- decodeFieldString
            loop (msg { mediumTitle = v})
          2 -> do
            v <- (fromIntegral <$> decodeFieldVarint)
            loop (msg { mediumCount = v})
          3 -> do
            v <- decodeFieldDouble
            loop (msg { mediumScore = v})
          4 -> do
            v <- decodeFieldBytes
            loop (msg { mediumPayload = v})
          5 -> do
            v <- decodeFieldBool
            loop (msg { mediumEnabled = v})
          6 -> do
            v <- (fromIntegral <$> decodeFieldVarint)
            loop (msg { mediumTimestamp = v})
          7 -> do
            v <- decodeFieldString
            loop (msg { mediumDescription = v})
          8 -> do
            v <- decodeFieldFloat
            loop (msg { mediumRatio = v})
          _ -> do
            uf <- captureUnknownField fn (toEnum wt)
            loop (msg { mediumUnknownFields = (uf : msg.mediumUnknownFields)}))

-- | Field descriptors for 'Medium', keyed by proto field number.
--
-- Top-level CAF: allocated lazily on first force, shared on every
-- subsequent 'protoFieldDescriptors' call (no per-call rebuild).
mediumFieldDescriptors :: IntMap.IntMap (SomeFieldDescriptor Medium)
mediumFieldDescriptors =
  IntMap.fromList
    [ (1, SomeField FieldDescriptor
        { fdName = "title"
        , fdNumber = 1
        , fdTypeDesc = ScalarType StringField
        , fdLabel = LabelOptional
        , fdGet = mediumTitle
        , fdSet = \v m -> m { mediumTitle = v }
        }), (2, SomeField FieldDescriptor
        { fdName = "count"
        , fdNumber = 2
        , fdTypeDesc = ScalarType Int32Field
        , fdLabel = LabelOptional
        , fdGet = mediumCount
        , fdSet = \v m -> m { mediumCount = v }
        })
    , (3, SomeField FieldDescriptor
        { fdName = "score"
        , fdNumber = 3
        , fdTypeDesc = ScalarType DoubleField
        , fdLabel = LabelOptional
        , fdGet = mediumScore
        , fdSet = \v m -> m { mediumScore = v }
        })
    , (4, SomeField FieldDescriptor
        { fdName = "payload"
        , fdNumber = 4
        , fdTypeDesc = ScalarType BytesField
        , fdLabel = LabelOptional
        , fdGet = mediumPayload
        , fdSet = \v m -> m { mediumPayload = v }
        })
    , (5, SomeField FieldDescriptor
        { fdName = "enabled"
        , fdNumber = 5
        , fdTypeDesc = ScalarType BoolField
        , fdLabel = LabelOptional
        , fdGet = mediumEnabled
        , fdSet = \v m -> m { mediumEnabled = v }
        })
    , (6, SomeField FieldDescriptor
        { fdName = "timestamp"
        , fdNumber = 6
        , fdTypeDesc = ScalarType Int64Field
        , fdLabel = LabelOptional
        , fdGet = mediumTimestamp
        , fdSet = \v m -> m { mediumTimestamp = v }
        })
    , (7, SomeField FieldDescriptor
        { fdName = "description"
        , fdNumber = 7
        , fdTypeDesc = ScalarType StringField
        , fdLabel = LabelOptional
        , fdGet = mediumDescription
        , fdSet = \v m -> m { mediumDescription = v }
        })
    , (8, SomeField FieldDescriptor
        { fdName = "ratio"
        , fdNumber = 8
        , fdTypeDesc = ScalarType FloatField
        , fdLabel = LabelOptional
        , fdGet = mediumRatio
        , fdSet = \v m -> m { mediumRatio = v }
        })
    ]

instance ProtoMessage Medium where
  protoMessageName _ = "bench.Medium"
  protoPackageName _ = "bench"
  protoDefaultValue = defaultMedium
  protoFileDescriptorBytes _ = fileDescriptorProtoBytes
  protoFieldDescriptors _ = mediumFieldDescriptors

instance IsMessage Medium

instance Aeson.ToJSON Medium where
  toJSON msg = jsonObject
      [ "title" .=: msg.mediumTitle
      , "count" .=: msg.mediumCount
      , "score" .=: msg.mediumScore
      , bytesFieldToJSON "payload" msg.mediumPayload
      , "enabled" .=: msg.mediumEnabled
      , "timestamp" .=: msg.mediumTimestamp
      , "description" .=: msg.mediumDescription
      , "ratio" .=: msg.mediumRatio
      ]

instance Aeson.FromJSON Medium where
  parseJSON = Aeson.withObject "Medium" $ \obj -> do
    fld_mediumTitle <- parseFieldMaybe obj "title"
    fld_mediumCount <- parseFieldMaybe obj "count"
    fld_mediumScore <- parseFieldMaybe obj "score"
    fld_mediumPayload <- parseBytesFieldMaybe obj "payload"
    fld_mediumEnabled <- parseFieldMaybe obj "enabled"
    fld_mediumTimestamp <- parseFieldMaybe obj "timestamp"
    fld_mediumDescription <- parseFieldMaybe obj "description"
    fld_mediumRatio <- parseFieldMaybe obj "ratio"
    pure defaultMedium
      { mediumTitle = maybe (mediumTitle defaultMedium) id fld_mediumTitle
      , mediumCount = maybe (mediumCount defaultMedium) id fld_mediumCount
      , mediumScore = maybe (mediumScore defaultMedium) id fld_mediumScore
      , mediumPayload = maybe (mediumPayload defaultMedium) id fld_mediumPayload
      , mediumEnabled = maybe (mediumEnabled defaultMedium) id fld_mediumEnabled
      , mediumTimestamp = maybe (mediumTimestamp defaultMedium) id fld_mediumTimestamp
      , mediumDescription = maybe (mediumDescription defaultMedium) id fld_mediumDescription
      , mediumRatio = maybe (mediumRatio defaultMedium) id fld_mediumRatio
      }

instance Hashable Medium where
  hashWithSalt salt msg = hashWithSalt (hashWithSalt (hashWithSalt (hashWithSalt (hashWithSalt (hashWithSalt (hashWithSalt (hashWithSalt (salt) msg.mediumTitle) msg.mediumCount) msg.mediumScore) msg.mediumPayload) msg.mediumEnabled) msg.mediumTimestamp) msg.mediumDescription) msg.mediumRatio

instance Proto.Extension.HasExtensions Medium where
  messageUnknownFields = mediumUnknownFields
  setMessageUnknownFields !ufs msg = msg { mediumUnknownFields = ufs }

instance Semigroup Medium where
  a <> b = Medium
    { mediumTitle = if b.mediumTitle == "" then a.mediumTitle else b.mediumTitle
    , mediumCount = if b.mediumCount == 0 then a.mediumCount else b.mediumCount
    , mediumScore = if b.mediumScore == 0 then a.mediumScore else b.mediumScore
    , mediumPayload = if b.mediumPayload == "" then a.mediumPayload else b.mediumPayload
    , mediumEnabled = if b.mediumEnabled == False then a.mediumEnabled else b.mediumEnabled
    , mediumTimestamp = if b.mediumTimestamp == 0 then a.mediumTimestamp else b.mediumTimestamp
    , mediumDescription = if b.mediumDescription == "" then a.mediumDescription else b.mediumDescription
    , mediumRatio = if b.mediumRatio == 0 then a.mediumRatio else b.mediumRatio
    , mediumUnknownFields = a.mediumUnknownFields <> b.mediumUnknownFields
    }

instance Monoid Medium where
  mempty = defaultMedium

data WithNested = WithNested
  { withNestedId :: {-# UNPACK #-} !Int64
  , withNestedInner :: !(Maybe Small)
  , withNestedLabel :: !Text
  , withNestedUnknownFields :: ![UnknownField]
  }
  deriving stock (Show, Eq, Generic)
  deriving anyclass NFData

defaultWithNested :: WithNested
defaultWithNested = WithNested
  { withNestedId = 0
  , withNestedInner = Nothing
  , withNestedLabel = ""
  , withNestedUnknownFields = []
  }

instance MessageEncode WithNested where
  buildSized msg =
    (if msg.withNestedId == 0 then mempty else archVarint 8 (fromIntegral msg.withNestedId))
    <> (maybe mempty (\v -> archSubmessage 18 (buildSized v)) msg.withNestedInner)
    <> (if msg.withNestedLabel == T.empty then mempty else archString 26 msg.withNestedLabel)
    <> encodeUnknownFieldsSized msg.withNestedUnknownFields

instance MessageDecode WithNested where
  {-# INLINE messageDecoder #-}
  messageDecoder = stage_0 defaultWithNested
    where
      stage_0 msg =
        inOrderStage1
          (0x8 :: Data.Word.Word8)
          (fromIntegral <$> decodeFieldVarint)
          (\v -> stage_1 (msg { withNestedId = v}))
          (pure (case msg.withNestedUnknownFields of { [] -> msg; _ -> msg { withNestedUnknownFields = reverse (msg.withNestedUnknownFields) } }))
          (loop msg)
      stage_1 msg =
        inOrderStage1
          (0x12 :: Data.Word.Word8)
          decodeFieldMessage
          (\v -> stage_2 (msg { withNestedInner = (Just v)}))
          (pure (case msg.withNestedUnknownFields of { [] -> msg; _ -> msg { withNestedUnknownFields = reverse (msg.withNestedUnknownFields) } }))
          (loop msg)
      stage_2 msg =
        inOrderStage1
          (0x1a :: Data.Word.Word8)
          decodeFieldString
          (\v -> loop (msg { withNestedLabel = v}))
          (pure (case msg.withNestedUnknownFields of { [] -> msg; _ -> msg { withNestedUnknownFields = reverse (msg.withNestedUnknownFields) } }))
          (loop msg)
      loop msg = withTagM
        (pure (case msg.withNestedUnknownFields of { [] -> msg; _ -> msg { withNestedUnknownFields = reverse (msg.withNestedUnknownFields) } }))
        (\fn wt -> case fn of
          1 -> do
            v <- (fromIntegral <$> decodeFieldVarint)
            loop (msg { withNestedId = v})
          2 -> do
            v <- decodeFieldMessage
            loop (msg { withNestedInner = (Just v)})
          3 -> do
            v <- decodeFieldString
            loop (msg { withNestedLabel = v})
          _ -> do
            uf <- captureUnknownField fn (toEnum wt)
            loop (msg { withNestedUnknownFields = (uf : msg.withNestedUnknownFields)}))

-- | Field descriptors for 'WithNested', keyed by proto field number.
--
-- Top-level CAF: allocated lazily on first force, shared on every
-- subsequent 'protoFieldDescriptors' call (no per-call rebuild).
withNestedFieldDescriptors :: IntMap.IntMap (SomeFieldDescriptor WithNested)
withNestedFieldDescriptors =
  IntMap.fromList
    [ (1, SomeField FieldDescriptor
        { fdName = "id"
        , fdNumber = 1
        , fdTypeDesc = ScalarType Int64Field
        , fdLabel = LabelOptional
        , fdGet = withNestedId
        , fdSet = \v m -> m { withNestedId = v }
        }), (2, SomeField FieldDescriptor
        { fdName = "inner"
        , fdNumber = 2
        , fdTypeDesc = MessageType "Small"
        , fdLabel = LabelOptional
        , fdGet = withNestedInner
        , fdSet = \v m -> m { withNestedInner = v }
        })
    , (3, SomeField FieldDescriptor
        { fdName = "label"
        , fdNumber = 3
        , fdTypeDesc = ScalarType StringField
        , fdLabel = LabelOptional
        , fdGet = withNestedLabel
        , fdSet = \v m -> m { withNestedLabel = v }
        })
    ]

instance ProtoMessage WithNested where
  protoMessageName _ = "bench.WithNested"
  protoPackageName _ = "bench"
  protoDefaultValue = defaultWithNested
  protoFileDescriptorBytes _ = fileDescriptorProtoBytes
  protoFieldDescriptors _ = withNestedFieldDescriptors

instance IsMessage WithNested

instance Aeson.ToJSON WithNested where
  toJSON msg = jsonObject
      [ "id" .=: msg.withNestedId
      , "inner" .=: msg.withNestedInner
      , "label" .=: msg.withNestedLabel
      ]

instance Aeson.FromJSON WithNested where
  parseJSON = Aeson.withObject "WithNested" $ \obj -> do
    fld_withNestedId <- parseFieldMaybe obj "id"
    fld_withNestedInner <- parseFieldMaybe obj "inner"
    fld_withNestedLabel <- parseFieldMaybe obj "label"
    pure defaultWithNested
      { withNestedId = maybe (withNestedId defaultWithNested) id fld_withNestedId
      , withNestedInner = maybe (withNestedInner defaultWithNested) id fld_withNestedInner
      , withNestedLabel = maybe (withNestedLabel defaultWithNested) id fld_withNestedLabel
      }

instance Hashable WithNested where
  hashWithSalt salt msg = hashWithSalt (hashWithSalt (hashWithSalt (salt) msg.withNestedId) msg.withNestedInner) msg.withNestedLabel

instance Proto.Extension.HasExtensions WithNested where
  messageUnknownFields = withNestedUnknownFields
  setMessageUnknownFields !ufs msg = msg { withNestedUnknownFields = ufs }

instance Semigroup WithNested where
  a <> b = WithNested
    { withNestedId = if b.withNestedId == 0 then a.withNestedId else b.withNestedId
    , withNestedInner = case b.withNestedInner of { Nothing -> a.withNestedInner; x -> x }
    , withNestedLabel = if b.withNestedLabel == "" then a.withNestedLabel else b.withNestedLabel
    , withNestedUnknownFields = a.withNestedUnknownFields <> b.withNestedUnknownFields
    }

instance Monoid WithNested where
  mempty = defaultWithNested

data WithRepeated = WithRepeated
  { withRepeatedValues :: !(VU.Vector Int32)
  , withRepeatedTags :: !(V.Vector Text)
  , withRepeatedItems :: !(V.Vector Small)
  , withRepeatedUnknownFields :: ![UnknownField]
  }
  deriving stock (Show, Eq, Generic)
  deriving anyclass NFData

defaultWithRepeated :: WithRepeated
defaultWithRepeated = WithRepeated
  { withRepeatedValues = VU.empty
  , withRepeatedTags = V.empty
  , withRepeatedItems = V.empty
  , withRepeatedUnknownFields = []
  }

instance MessageEncode WithRepeated where
  buildSized msg =
    encodePackedInt32 1 msg.withRepeatedValues
    <> V.foldl' (\acc v -> acc <> archString 18 v) mempty msg.withRepeatedTags
    <> V.foldl' (\acc v -> acc <> archSubmessage 26 (buildSized v)) mempty msg.withRepeatedItems
    <> encodeUnknownFieldsSized msg.withRepeatedUnknownFields

instance MessageDecode WithRepeated where
  {-# INLINE messageDecoder #-}
  messageDecoder = stage_0 defaultWithRepeated emptyGrowList emptyGrowList
    where
      stage_0 msg gl_0 gl_1 =
        inOrderStage1
          (0xa :: Data.Word.Word8)
          (VU.map fromIntegral <$> decodePackedVarint)
          (\v -> stage_1 (msg { withRepeatedValues = v}) gl_0 gl_1)
          (pure (case msg.withRepeatedUnknownFields of { [] -> msg { withRepeatedTags = growListToVector gl_0, withRepeatedItems = growListToVector gl_1 }; _ -> msg { withRepeatedTags = growListToVector gl_0, withRepeatedItems = growListToVector gl_1, withRepeatedUnknownFields = reverse (msg.withRepeatedUnknownFields) } }))
          (loop msg gl_0 gl_1)
      stage_1 msg gl_0 gl_1 =
        inOrderStage1
          (0x12 :: Data.Word.Word8)
          decodeFieldString
          (\v -> stage_1 msg (snocGrowList gl_0 v) gl_1)
          (pure (case msg.withRepeatedUnknownFields of { [] -> msg { withRepeatedTags = growListToVector gl_0, withRepeatedItems = growListToVector gl_1 }; _ -> msg { withRepeatedTags = growListToVector gl_0, withRepeatedItems = growListToVector gl_1, withRepeatedUnknownFields = reverse (msg.withRepeatedUnknownFields) } }))
          (loop msg gl_0 gl_1)
      stage_2 msg gl_0 gl_1 =
        inOrderStage1
          (0x1a :: Data.Word.Word8)
          decodeFieldMessage
          (\v -> stage_2 msg gl_0 (snocGrowList gl_1 v))
          (pure (case msg.withRepeatedUnknownFields of { [] -> msg { withRepeatedTags = growListToVector gl_0, withRepeatedItems = growListToVector gl_1 }; _ -> msg { withRepeatedTags = growListToVector gl_0, withRepeatedItems = growListToVector gl_1, withRepeatedUnknownFields = reverse (msg.withRepeatedUnknownFields) } }))
          (loop msg gl_0 gl_1)
      loop msg gl_0 gl_1 = withTagM
        (pure (case msg.withRepeatedUnknownFields of { [] -> msg { withRepeatedTags = growListToVector gl_0, withRepeatedItems = growListToVector gl_1 }; _ -> msg { withRepeatedTags = growListToVector gl_0, withRepeatedItems = growListToVector gl_1, withRepeatedUnknownFields = reverse (msg.withRepeatedUnknownFields) } }))
        (\fn wt -> case fn of
          1 -> case wt of
            2 -> do
              vs <- (VU.map fromIntegral <$> decodePackedVarint)
              loop (msg { withRepeatedValues = (msg.withRepeatedValues <> vs)}) gl_0 gl_1
            _ -> do
              v <- (fromIntegral <$> decodeFieldVarint)
              loop (msg { withRepeatedValues = (VU.snoc msg.withRepeatedValues v)}) gl_0 gl_1
          2 -> do
            v <- decodeFieldString
            loop msg (snocGrowList gl_0 v) gl_1
          3 -> do
            v <- decodeFieldMessage
            loop msg gl_0 (snocGrowList gl_1 v)
          _ -> do
            uf <- captureUnknownField fn (toEnum wt)
            loop (msg { withRepeatedUnknownFields = (uf : msg.withRepeatedUnknownFields)}) gl_0 gl_1)

-- | Field descriptors for 'WithRepeated', keyed by proto field number.
--
-- Top-level CAF: allocated lazily on first force, shared on every
-- subsequent 'protoFieldDescriptors' call (no per-call rebuild).
withRepeatedFieldDescriptors :: IntMap.IntMap (SomeFieldDescriptor WithRepeated)
withRepeatedFieldDescriptors =
  IntMap.fromList
    [ (1, SomeField FieldDescriptor
        { fdName = "values"
        , fdNumber = 1
        , fdTypeDesc = ScalarType Int32Field
        , fdLabel = LabelRepeated
        , fdGet = withRepeatedValues
        , fdSet = \v m -> m { withRepeatedValues = v }
        }), (2, SomeField FieldDescriptor
        { fdName = "tags"
        , fdNumber = 2
        , fdTypeDesc = ScalarType StringField
        , fdLabel = LabelRepeated
        , fdGet = withRepeatedTags
        , fdSet = \v m -> m { withRepeatedTags = v }
        })
    , (3, SomeField FieldDescriptor
        { fdName = "items"
        , fdNumber = 3
        , fdTypeDesc = MessageType "Small"
        , fdLabel = LabelRepeated
        , fdGet = withRepeatedItems
        , fdSet = \v m -> m { withRepeatedItems = v }
        })
    ]

instance ProtoMessage WithRepeated where
  protoMessageName _ = "bench.WithRepeated"
  protoPackageName _ = "bench"
  protoDefaultValue = defaultWithRepeated
  protoFileDescriptorBytes _ = fileDescriptorProtoBytes
  protoFieldDescriptors _ = withRepeatedFieldDescriptors

instance IsMessage WithRepeated

instance Aeson.ToJSON WithRepeated where
  toJSON msg = jsonObject
      [ "values" .=: msg.withRepeatedValues
      , "tags" .=: msg.withRepeatedTags
      , "items" .=: msg.withRepeatedItems
      ]

instance Aeson.FromJSON WithRepeated where
  parseJSON = Aeson.withObject "WithRepeated" $ \obj -> do
    fld_withRepeatedValues <- parseFieldMaybe obj "values"
    fld_withRepeatedTags <- parseFieldMaybe obj "tags"
    fld_withRepeatedItems <- parseFieldMaybe obj "items"
    pure defaultWithRepeated
      { withRepeatedValues = maybe (withRepeatedValues defaultWithRepeated) id fld_withRepeatedValues
      , withRepeatedTags = maybe (withRepeatedTags defaultWithRepeated) id fld_withRepeatedTags
      , withRepeatedItems = maybe (withRepeatedItems defaultWithRepeated) id fld_withRepeatedItems
      }

instance Hashable WithRepeated where
  hashWithSalt salt msg = V.foldl' hashWithSalt (V.foldl' hashWithSalt (VU.foldl' hashWithSalt (salt) msg.withRepeatedValues) msg.withRepeatedTags) msg.withRepeatedItems

instance Proto.Extension.HasExtensions WithRepeated where
  messageUnknownFields = withRepeatedUnknownFields
  setMessageUnknownFields !ufs msg = msg { withRepeatedUnknownFields = ufs }

instance Semigroup WithRepeated where
  a <> b = WithRepeated
    { withRepeatedValues = a.withRepeatedValues <> b.withRepeatedValues
    , withRepeatedTags = a.withRepeatedTags <> b.withRepeatedTags
    , withRepeatedItems = a.withRepeatedItems <> b.withRepeatedItems
    , withRepeatedUnknownFields = a.withRepeatedUnknownFields <> b.withRepeatedUnknownFields
    }

instance Monoid WithRepeated where
  mempty = defaultWithRepeated