wireform-proto-0.3.0.0: test-regression/Generated/Edition2023.hs
{-# LANGUAGE StrictData #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE OverloadedRecordDot #-}
{-# OPTIONS_GHC -Wno-unused-imports -Wno-unused-matches -Wno-unused-top-binds #-}
-- | Auto-generated protobuf types.
--
-- __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 Generated.Edition2023 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 (Word32, Word64)
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.Encode
import Proto.Decode
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)
import Data.Proxy (Proxy(..))
import Data.Reflection (Given(..), given)
import Proto.Internal.JSON.Extension qualified as PJExt
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, fieldMessageSize,
fieldVarintSize, fieldFixed32Size, fieldFixed64Size,
fieldBoolSize, fieldFloatSize, fieldDoubleSize,
fieldTextSize, fieldBytesSize,
fieldSVarint32Size, fieldSVarint64Size,
varintSize32, zigZag32, zigZag64)
import Proto.Internal.Encode.Archetype (archVarint, archSVarint32, archSVarint64,
archFixed32, archFixed64, archFloat, archDouble, archBool,
archString, archBytes, archSubmessage,
archVarintSize, archStringSize, archBytesSize, archBoolSize,
archFixed32Size, archFixed64Size, archSubmessageSize)
-- | Serialized FileDescriptorProto for this .proto file.
-- Decode with @Proto.Google.Protobuf.Descriptor.decodeMessage@.
fileDescriptorProtoBytes :: ByteString
fileDescriptorProtoBytes = "\x0a\x11\x65\x64\x69\x74\x69\x6f\x6e\x32\x30\x32\x33\x2e\x70\x72\x6f\x74\x6f\x22\xbe\x02\x0a\x08\x46\x69\x65\x6c\x64\x73\x32\x33\x12\x0d\x0a\x05\x63\x6f\x75\x6e\x74\x18\x01\x20\x01\x28\x05\x12\x0c\x0a\x04\x6e\x61\x6d\x65\x18\x02\x20\x01\x28\x09\x12\x0f\x0a\x07\x70\x61\x79\x6c\x6f\x61\x64\x18\x03\x20\x01\x28\x0c\x12\x0f\x0a\x07\x65\x6e\x61\x62\x6c\x65\x64\x18\x04\x20\x01\x28\x08\x12\x18\x0a\x06\x73\x74\x61\x74\x75\x73\x18\x05\x20\x01\x28\x0b\x32\x08\x53\x74\x61\x74\x75\x73\x32\x33\x12\x11\x0a\x09\x6d\x61\x67\x6e\x69\x74\x75\x64\x65\x18\x06\x20\x01\x28\x01\x12\x10\x0a\x08\x66\x72\x61\x63\x74\x69\x6f\x6e\x18\x07\x20\x01\x28\x02\x12\x16\x0a\x0e\x69\x6d\x70\x6c\x69\x63\x69\x74\x5f\x63\x6f\x75\x6e\x74\x18\x08\x20\x01\x28\x05\x12\x0e\x0a\x06\x76\x61\x6c\x75\x65\x73\x18\x09\x20\x03\x28\x05\x12\x14\x0a\x05\x69\x6e\x6e\x65\x72\x18\x0a\x20\x01\x28\x0b\x32\x05\x49\x6e\x6e\x65\x72\x12\x19\x0a\x05\x61\x74\x74\x72\x73\x18\x0b\x20\x03\x28\x0b\x32\x0a\x61\x74\x74\x72\x73\x45\x6e\x74\x72\x79\x12\x0e\x0a\x06\x70\x69\x63\x6b\x65\x64\x18\x0c\x20\x01\x28\x05\x12\x0d\x0a\x05\x6c\x61\x62\x65\x6c\x18\x0d\x20\x01\x28\x09\x12\x1a\x0a\x12\x61\x67\x67\x72\x65\x67\x61\x74\x65\x5f\x69\x6d\x70\x6c\x69\x63\x69\x74\x18\x0e\x20\x01\x28\x05\x1a\x16\x0a\x05\x49\x6e\x6e\x65\x72\x12\x0d\x0a\x05\x63\x6f\x75\x6e\x74\x18\x01\x20\x01\x28\x05\x42\x08\x0a\x06\x63\x68\x6f\x69\x63\x65\x2a\x36\x0a\x08\x53\x74\x61\x74\x75\x73\x32\x33\x12\x16\x0a\x14\x53\x54\x41\x54\x55\x53\x32\x33\x5f\x55\x4e\x53\x50\x45\x43\x49\x46\x49\x45\x44\x12\x12\x0a\x0e\x53\x54\x41\x54\x55\x53\x32\x33\x5f\x52\x45\x41\x44\x59\x10\x01\x62\x08\x65\x64\x69\x74\x69\x6f\x6e\x73\x72\x04\x32\x30\x32\x33"
data Status23
= Status23'Status23Unspecified
| Status23'Status23Ready
deriving stock (Show, Eq, Ord, Enum, Bounded, Generic)
deriving anyclass NFData
toProtoEnumStatus23 :: Status23 -> Int
toProtoEnumStatus23 Status23'Status23Unspecified = 0
toProtoEnumStatus23 Status23'Status23Ready = 1
fromProtoEnumStatus23 :: Int -> Maybe Status23
fromProtoEnumStatus23 0 = Just Status23'Status23Unspecified
fromProtoEnumStatus23 1 = Just Status23'Status23Ready
fromProtoEnumStatus23 _ = Nothing
instance MessageEncode Status23 where
buildMessage _ = mempty
instance MessageSize Status23 where
messageSize _ = 0
instance MessageDecode Status23 where
messageDecoder = pure (toEnum 0)
instance Aeson.ToJSON Status23 where
toJSON Status23'Status23Unspecified = Aeson.String "STATUS23_UNSPECIFIED"
toJSON Status23'Status23Ready = Aeson.String "STATUS23_READY"
instance Aeson.FromJSON Status23 where
parseJSON = \case
Aeson.String "STATUS23_UNSPECIFIED" -> pure Status23'Status23Unspecified
Aeson.String "STATUS23_READY" -> pure Status23'Status23Ready
Aeson.Number n -> pure (toEnum (round n))
_ -> fail "Invalid enum value for Status23"
instance Hashable Status23 where
hashWithSalt salt x = hashWithSalt salt (toProtoEnumStatus23 x)
data Fields23 = Fields23
{ fields23Count :: !(Maybe Int32)
, fields23Name :: !(Maybe Text)
, fields23Payload :: !(Maybe ByteString)
, fields23Enabled :: !(Maybe Bool)
, fields23Status :: !(Maybe Status23)
, fields23Magnitude :: !(Maybe Double)
, fields23Fraction :: !(Maybe Float)
, fields23ImplicitCount :: {-# UNPACK #-} !Int32
, fields23Values :: !(VU.Vector Int32)
, fields23Inner :: !(Maybe Fields23'Inner)
, fields23Attrs :: !(Map.Map Text Text)
, fields23Choice :: !(Maybe Fields23'Choice)
, fields23AggregateImplicit :: {-# UNPACK #-} !Int32
, fields23UnknownFields :: ![UnknownField]
}
deriving stock (Show, Eq, Generic)
deriving anyclass NFData
data Fields23'Inner = Fields23'Inner
{ fields23InnerCount :: !(Maybe Int32)
, fields23InnerUnknownFields :: ![UnknownField]
}
deriving stock (Show, Eq, Generic)
deriving anyclass NFData
defaultFields23'Inner :: Fields23'Inner
defaultFields23'Inner = Fields23'Inner
{ fields23InnerCount = Nothing
, fields23InnerUnknownFields = []
}
instance MessageEncode Fields23'Inner where
buildMessage msg =
(maybe mempty (\v -> archVarint 8 (fromIntegral v)) msg.fields23InnerCount)
<> encodeUnknownFields msg.fields23InnerUnknownFields
instance MessageSize Fields23'Inner where
messageSize msg =
(maybe 0 (\v -> archVarintSize (fromIntegral v)) msg.fields23InnerCount)
+ unknownFieldsSize msg.fields23InnerUnknownFields
instance MessageDecode Fields23'Inner where
{-# INLINE messageDecoder #-}
messageDecoder = loop Nothing []
where
loop acc_0 acc_unknown_ = withTagM
(pure (Fields23'Inner {fields23InnerCount = acc_0, fields23InnerUnknownFields = reverse acc_unknown_}))
(\fn wt -> case fn of
1 -> do
v <- (fromIntegral <$> decodeFieldVarint)
loop (Just v) acc_unknown_
_ -> do
uf <- captureUnknownField fn (toEnum wt)
loop acc_0 (uf : acc_unknown_))
instance ProtoMessage Fields23'Inner where
protoMessageName _ = "Fields23.Inner"
protoPackageName _ = ""
protoDefaultValue = defaultFields23'Inner
protoFileDescriptorBytes _ = fileDescriptorProtoBytes
protoFieldDescriptors _ = Map.fromList
[ (1, SomeField FieldDescriptor
{ fdName = "count"
, fdNumber = 1
, fdTypeDesc = ScalarType Int32Field
, fdLabel = LabelOptional
, fdGet = fields23InnerCount
, fdSet = \v m -> m { fields23InnerCount = v }
})
]
instance IsMessage Fields23'Inner
instance Aeson.ToJSON Fields23'Inner where
toJSON msg = jsonObject
[ "count" .=: msg.fields23InnerCount
]
instance Aeson.FromJSON Fields23'Inner where
parseJSON = Aeson.withObject "Fields23'Inner" $ \obj -> do
fld_fields23InnerCount <- parseFieldMaybe obj "count"
pure defaultFields23'Inner
{ fields23InnerCount = maybe (fields23InnerCount defaultFields23'Inner) id fld_fields23InnerCount
, fields23InnerUnknownFields = []
}
instance Hashable Fields23'Inner where
hashWithSalt salt msg = hashWithSalt (salt) msg.fields23InnerCount
instance Proto.Extension.HasExtensions Fields23'Inner where
messageUnknownFields = fields23InnerUnknownFields
setMessageUnknownFields !ufs msg = msg { fields23InnerUnknownFields = ufs }
instance Semigroup Fields23'Inner where
a <> b = Fields23'Inner
{ fields23InnerCount = case b.fields23InnerCount of { Nothing -> a.fields23InnerCount; x -> x }
, fields23InnerUnknownFields = a.fields23InnerUnknownFields <> b.fields23InnerUnknownFields
}
instance Monoid Fields23'Inner where
mempty = defaultFields23'Inner
data Fields23'Choice
= Fields23'Choice'Picked {-# UNPACK #-} !Int32
| Fields23'Choice'Label !Text
deriving stock (Show, Eq, Generic)
deriving anyclass NFData
instance Aeson.ToJSON Fields23'Choice where
toJSON _ = Aeson.Null
instance Aeson.FromJSON Fields23'Choice where
parseJSON _ = fail "Cannot parse oneof from JSON"
instance Hashable Fields23'Choice where
hashWithSalt salt (Fields23'Choice'Picked v) = salt `hashWithSalt` (0 :: Int) `hashWithSalt` v
hashWithSalt salt (Fields23'Choice'Label v) = salt `hashWithSalt` (1 :: Int) `hashWithSalt` v
defaultFields23 :: Fields23
defaultFields23 = Fields23
{ fields23Count = Nothing
, fields23Name = Nothing
, fields23Payload = Nothing
, fields23Enabled = Nothing
, fields23Status = Nothing
, fields23Magnitude = Nothing
, fields23Fraction = Nothing
, fields23ImplicitCount = 0
, fields23Values = VU.empty
, fields23Inner = Nothing
, fields23Attrs = Map.empty
, fields23Choice = Nothing
, fields23AggregateImplicit = 0
, fields23UnknownFields = []
}
instance MessageEncode Fields23 where
buildMessage msg =
(maybe mempty (\v -> archVarint 8 (fromIntegral v)) msg.fields23Count)
<> (maybe mempty (\v -> archString 18 v) msg.fields23Name)
<> (maybe mempty (\v -> archBytes 26 v) msg.fields23Payload)
<> (maybe mempty (\v -> archBool 32 v) msg.fields23Enabled)
<> (maybe mempty (\v -> archVarint 40 (fromIntegral (fromEnum v))) msg.fields23Status)
<> (maybe mempty (\v -> archDouble 49 v) msg.fields23Magnitude)
<> (maybe mempty (\v -> archFloat 61 v) msg.fields23Fraction)
<> (if msg.fields23ImplicitCount == 0 then mempty else archVarint 64 (fromIntegral msg.fields23ImplicitCount))
<> encodePackedInt32 9 msg.fields23Values
<> (maybe mempty (\v -> let sz = messageSize v in archSubmessage 82 sz (buildMessage v)) msg.fields23Inner)
<> Map.foldlWithKey' (\acc k v -> acc <> encodeMapField 11 (encodeFieldString 1 k) (encodeFieldString 2 v)) mempty msg.fields23Attrs
<> (case msg.fields23Choice of
Nothing -> mempty
Just (Fields23'Choice'Picked v) -> archVarint 96 (fromIntegral v)
Just (Fields23'Choice'Label v) -> archString 106 v)
<> (if msg.fields23AggregateImplicit == 0 then mempty else archVarint 112 (fromIntegral msg.fields23AggregateImplicit))
<> encodeUnknownFields msg.fields23UnknownFields
instance MessageSize Fields23 where
messageSize msg =
(maybe 0 (\v -> archVarintSize (fromIntegral v)) msg.fields23Count)
+ (maybe 0 (\v -> archStringSize v) msg.fields23Name)
+ (maybe 0 (\v -> archBytesSize v) msg.fields23Payload)
+ (maybe 0 (\v -> archBoolSize) msg.fields23Enabled)
+ (maybe 0 (\v -> archVarintSize (fromIntegral (fromEnum v))) msg.fields23Status)
+ (maybe 0 (\v -> archFixed64Size) msg.fields23Magnitude)
+ (maybe 0 (\v -> archFixed32Size) msg.fields23Fraction)
+ (if msg.fields23ImplicitCount == 0 then 0 else archVarintSize (fromIntegral msg.fields23ImplicitCount))
+ (let pl = VU.foldl' (\a v -> a + varintSize (fromIntegral v)) 0 msg.fields23Values in if pl == 0 then 0 else tagSize 9 + varintSize (fromIntegral pl) + pl)
+ (maybe 0 (\v -> archSubmessageSize (messageSize v)) msg.fields23Inner)
+ (Map.foldlWithKey' (\acc k v -> let entrySz = fieldTextSize 1 k + fieldTextSize 2 v in acc + tagSize 11 + varintSize (fromIntegral entrySz) + entrySz) 0 msg.fields23Attrs)
+ (case msg.fields23Choice of { Nothing -> 0; Just (Fields23'Choice'Picked v) -> archVarintSize (fromIntegral v)
; Just (Fields23'Choice'Label v) -> archStringSize v })
+ (if msg.fields23AggregateImplicit == 0 then 0 else archVarintSize (fromIntegral msg.fields23AggregateImplicit))
+ unknownFieldsSize msg.fields23UnknownFields
instance MessageDecode Fields23 where
{-# INLINE messageDecoder #-}
messageDecoder = loop Nothing Nothing Nothing Nothing Nothing Nothing Nothing 0 VU.empty Nothing Map.empty Nothing 0 []
where
loop acc_0 acc_1 acc_2 acc_3 acc_4 acc_5 acc_6 acc_7 acc_8 acc_9 acc_10 acc_11 acc_12 acc_unknown_ = withTagM
(pure (Fields23 {fields23Count = acc_0, fields23Name = acc_1, fields23Payload = acc_2, fields23Enabled = acc_3, fields23Status = acc_4, fields23Magnitude = acc_5, fields23Fraction = acc_6, fields23ImplicitCount = acc_7, fields23Values = acc_8, fields23Inner = acc_9, fields23Attrs = acc_10, fields23Choice = acc_11, fields23AggregateImplicit = acc_12, fields23UnknownFields = reverse acc_unknown_}))
(\fn wt -> case fn of
1 -> do
v <- (fromIntegral <$> decodeFieldVarint)
loop (Just v) acc_1 acc_2 acc_3 acc_4 acc_5 acc_6 acc_7 acc_8 acc_9 acc_10 acc_11 acc_12 acc_unknown_
2 -> do
v <- decodeFieldString
loop acc_0 (Just v) acc_2 acc_3 acc_4 acc_5 acc_6 acc_7 acc_8 acc_9 acc_10 acc_11 acc_12 acc_unknown_
3 -> do
v <- decodeFieldBytes
loop acc_0 acc_1 (Just v) acc_3 acc_4 acc_5 acc_6 acc_7 acc_8 acc_9 acc_10 acc_11 acc_12 acc_unknown_
4 -> do
v <- decodeFieldBool
loop acc_0 acc_1 acc_2 (Just v) acc_4 acc_5 acc_6 acc_7 acc_8 acc_9 acc_10 acc_11 acc_12 acc_unknown_
5 -> do
v <- decodeFieldEnum
loop acc_0 acc_1 acc_2 acc_3 (Just v) acc_5 acc_6 acc_7 acc_8 acc_9 acc_10 acc_11 acc_12 acc_unknown_
6 -> do
v <- decodeFieldDouble
loop acc_0 acc_1 acc_2 acc_3 acc_4 (Just v) acc_6 acc_7 acc_8 acc_9 acc_10 acc_11 acc_12 acc_unknown_
7 -> do
v <- decodeFieldFloat
loop acc_0 acc_1 acc_2 acc_3 acc_4 acc_5 (Just v) acc_7 acc_8 acc_9 acc_10 acc_11 acc_12 acc_unknown_
8 -> do
v <- (fromIntegral <$> decodeFieldVarint)
loop acc_0 acc_1 acc_2 acc_3 acc_4 acc_5 acc_6 v acc_8 acc_9 acc_10 acc_11 acc_12 acc_unknown_
9 -> case wt of
2 -> do
vs <- (VU.map fromIntegral <$> decodePackedVarint)
loop acc_0 acc_1 acc_2 acc_3 acc_4 acc_5 acc_6 acc_7 (acc_8 <> vs) acc_9 acc_10 acc_11 acc_12 acc_unknown_
_ -> do
v <- (fromIntegral <$> decodeFieldVarint)
loop acc_0 acc_1 acc_2 acc_3 acc_4 acc_5 acc_6 acc_7 (acc_8 <> VU.singleton v) acc_9 acc_10 acc_11 acc_12 acc_unknown_
10 -> do
v <- decodeFieldMessage
loop acc_0 acc_1 acc_2 acc_3 acc_4 acc_5 acc_6 acc_7 acc_8 (Just v) acc_10 acc_11 acc_12 acc_unknown_
11 -> do
bs' <- getLengthDelimited
let decodeEntry = runDecoder (decodeMapEntry decodeFieldString decodeFieldString "" "") bs'
case decodeEntry of
Left _ -> loop acc_0 acc_1 acc_2 acc_3 acc_4 acc_5 acc_6 acc_7 acc_8 acc_9 acc_10 acc_11 acc_12 acc_unknown_
Right (mk', mv') -> loop acc_0 acc_1 acc_2 acc_3 acc_4 acc_5 acc_6 acc_7 acc_8 acc_9 (Map.union acc_10 (Map.singleton mk' mv')) acc_11 acc_12 acc_unknown_
12 -> do
v <- (fromIntegral <$> decodeFieldVarint)
loop acc_0 acc_1 acc_2 acc_3 acc_4 acc_5 acc_6 acc_7 acc_8 acc_9 acc_10 (Just (Fields23'Choice'Picked v)) acc_12 acc_unknown_
13 -> do
v <- decodeFieldString
loop acc_0 acc_1 acc_2 acc_3 acc_4 acc_5 acc_6 acc_7 acc_8 acc_9 acc_10 (Just (Fields23'Choice'Label v)) acc_12 acc_unknown_
14 -> do
v <- (fromIntegral <$> decodeFieldVarint)
loop acc_0 acc_1 acc_2 acc_3 acc_4 acc_5 acc_6 acc_7 acc_8 acc_9 acc_10 acc_11 v acc_unknown_
_ -> do
uf <- captureUnknownField fn (toEnum wt)
loop acc_0 acc_1 acc_2 acc_3 acc_4 acc_5 acc_6 acc_7 acc_8 acc_9 acc_10 acc_11 acc_12 (uf : acc_unknown_))
instance ProtoMessage Fields23 where
protoMessageName _ = "Fields23"
protoPackageName _ = ""
protoDefaultValue = defaultFields23
protoFileDescriptorBytes _ = fileDescriptorProtoBytes
protoFieldDescriptors _ = Map.fromList
[ (1, SomeField FieldDescriptor
{ fdName = "count"
, fdNumber = 1
, fdTypeDesc = ScalarType Int32Field
, fdLabel = LabelOptional
, fdGet = fields23Count
, fdSet = \v m -> m { fields23Count = v }
}), (2, SomeField FieldDescriptor
{ fdName = "name"
, fdNumber = 2
, fdTypeDesc = ScalarType StringField
, fdLabel = LabelOptional
, fdGet = fields23Name
, fdSet = \v m -> m { fields23Name = v }
})
, (3, SomeField FieldDescriptor
{ fdName = "payload"
, fdNumber = 3
, fdTypeDesc = ScalarType BytesField
, fdLabel = LabelOptional
, fdGet = fields23Payload
, fdSet = \v m -> m { fields23Payload = v }
})
, (4, SomeField FieldDescriptor
{ fdName = "enabled"
, fdNumber = 4
, fdTypeDesc = ScalarType BoolField
, fdLabel = LabelOptional
, fdGet = fields23Enabled
, fdSet = \v m -> m { fields23Enabled = v }
})
, (5, SomeField FieldDescriptor
{ fdName = "status"
, fdNumber = 5
, fdTypeDesc = MessageType "Status23"
, fdLabel = LabelOptional
, fdGet = fields23Status
, fdSet = \v m -> m { fields23Status = v }
})
, (6, SomeField FieldDescriptor
{ fdName = "magnitude"
, fdNumber = 6
, fdTypeDesc = ScalarType DoubleField
, fdLabel = LabelOptional
, fdGet = fields23Magnitude
, fdSet = \v m -> m { fields23Magnitude = v }
})
, (7, SomeField FieldDescriptor
{ fdName = "fraction"
, fdNumber = 7
, fdTypeDesc = ScalarType FloatField
, fdLabel = LabelOptional
, fdGet = fields23Fraction
, fdSet = \v m -> m { fields23Fraction = v }
})
, (8, SomeField FieldDescriptor
{ fdName = "implicit_count"
, fdNumber = 8
, fdTypeDesc = ScalarType Int32Field
, fdLabel = LabelOptional
, fdGet = fields23ImplicitCount
, fdSet = \v m -> m { fields23ImplicitCount = v }
})
, (9, SomeField FieldDescriptor
{ fdName = "values"
, fdNumber = 9
, fdTypeDesc = ScalarType Int32Field
, fdLabel = LabelRepeated
, fdGet = fields23Values
, fdSet = \v m -> m { fields23Values = v }
})
, (10, SomeField FieldDescriptor
{ fdName = "inner"
, fdNumber = 10
, fdTypeDesc = MessageType "Inner"
, fdLabel = LabelOptional
, fdGet = fields23Inner
, fdSet = \v m -> m { fields23Inner = v }
})
, (11, SomeField FieldDescriptor
{ fdName = "attrs"
, fdNumber = 11
, fdTypeDesc = ScalarType BytesField
, fdLabel = LabelRepeated
, fdGet = fields23Attrs
, fdSet = \v m -> m { fields23Attrs = v }
})
, (12, SomeField FieldDescriptor
{ fdName = "choice"
, fdNumber = 12
, fdTypeDesc = MessageType "choice"
, fdLabel = LabelOptional
, fdGet = fields23Choice
, fdSet = \v m -> m { fields23Choice = v }
})
, (14, SomeField FieldDescriptor
{ fdName = "aggregate_implicit"
, fdNumber = 14
, fdTypeDesc = ScalarType Int32Field
, fdLabel = LabelOptional
, fdGet = fields23AggregateImplicit
, fdSet = \v m -> m { fields23AggregateImplicit = v }
})
]
instance IsMessage Fields23
instance Aeson.ToJSON Fields23 where
toJSON msg = jsonObject
[ "count" .=: msg.fields23Count
, "name" .=: msg.fields23Name
, "payload" .=: (fmap protoBytesToJSON msg.fields23Payload)
, "enabled" .=: msg.fields23Enabled
, "status" .=: msg.fields23Status
, "magnitude" .=: msg.fields23Magnitude
, "fraction" .=: msg.fields23Fraction
, "implicitCount" .=: msg.fields23ImplicitCount
, "values" .=: msg.fields23Values
, "inner" .=: msg.fields23Inner
, "attrs" .=: msg.fields23Attrs
, "choice" .=: msg.fields23Choice
, "aggregateImplicit" .=: msg.fields23AggregateImplicit
]
instance Aeson.FromJSON Fields23 where
parseJSON = Aeson.withObject "Fields23" $ \obj -> do
fld_fields23Count <- parseFieldMaybe obj "count"
fld_fields23Name <- parseFieldMaybe obj "name"
fld_fields23Payload <- parseBytesFieldMaybe obj "payload"
fld_fields23Enabled <- parseFieldMaybe obj "enabled"
fld_fields23Status <- parseFieldMaybe obj "status"
fld_fields23Magnitude <- parseFieldMaybe obj "magnitude"
fld_fields23Fraction <- parseFieldMaybe obj "fraction"
fld_fields23ImplicitCount <- parseFieldMaybe obj "implicitCount"
fld_fields23Values <- parseFieldMaybe obj "values"
fld_fields23Inner <- parseFieldMaybe obj "inner"
fld_fields23Attrs <- parseFieldMaybe obj "attrs"
fld_fields23Choice <- parseFieldMaybe obj "choice"
fld_fields23AggregateImplicit <- parseFieldMaybe obj "aggregateImplicit"
pure defaultFields23
{ fields23Count = maybe (fields23Count defaultFields23) id fld_fields23Count
, fields23Name = maybe (fields23Name defaultFields23) id fld_fields23Name
, fields23Payload = fld_fields23Payload
, fields23Enabled = maybe (fields23Enabled defaultFields23) id fld_fields23Enabled
, fields23Status = maybe (fields23Status defaultFields23) id fld_fields23Status
, fields23Magnitude = maybe (fields23Magnitude defaultFields23) id fld_fields23Magnitude
, fields23Fraction = maybe (fields23Fraction defaultFields23) id fld_fields23Fraction
, fields23ImplicitCount = maybe (fields23ImplicitCount defaultFields23) id fld_fields23ImplicitCount
, fields23Values = maybe (fields23Values defaultFields23) id fld_fields23Values
, fields23Inner = maybe (fields23Inner defaultFields23) id fld_fields23Inner
, fields23Attrs = maybe (fields23Attrs defaultFields23) id fld_fields23Attrs
, fields23Choice = maybe (fields23Choice defaultFields23) id fld_fields23Choice
, fields23AggregateImplicit = maybe (fields23AggregateImplicit defaultFields23) id fld_fields23AggregateImplicit
, fields23UnknownFields = []
}
instance Hashable Fields23 where
hashWithSalt salt msg = hashWithSalt (hashWithSalt (Map.foldlWithKey' (\s k v -> s `hashWithSalt` k `hashWithSalt` v) (hashWithSalt (VU.foldl' hashWithSalt (hashWithSalt (hashWithSalt (hashWithSalt (hashWithSalt (hashWithSalt (hashWithSalt (hashWithSalt (hashWithSalt (salt) msg.fields23Count) msg.fields23Name) msg.fields23Payload) msg.fields23Enabled) msg.fields23Status) msg.fields23Magnitude) msg.fields23Fraction) msg.fields23ImplicitCount) msg.fields23Values) msg.fields23Inner) msg.fields23Attrs) msg.fields23Choice) msg.fields23AggregateImplicit
instance Proto.Extension.HasExtensions Fields23 where
messageUnknownFields = fields23UnknownFields
setMessageUnknownFields !ufs msg = msg { fields23UnknownFields = ufs }
instance Semigroup Fields23 where
a <> b = Fields23
{ fields23Count = case b.fields23Count of { Nothing -> a.fields23Count; x -> x }
, fields23Name = case b.fields23Name of { Nothing -> a.fields23Name; x -> x }
, fields23Payload = case b.fields23Payload of { Nothing -> a.fields23Payload; x -> x }
, fields23Enabled = case b.fields23Enabled of { Nothing -> a.fields23Enabled; x -> x }
, fields23Status = case b.fields23Status of { Nothing -> a.fields23Status; x -> x }
, fields23Magnitude = case b.fields23Magnitude of { Nothing -> a.fields23Magnitude; x -> x }
, fields23Fraction = case b.fields23Fraction of { Nothing -> a.fields23Fraction; x -> x }
, fields23ImplicitCount = if b.fields23ImplicitCount == 0 then a.fields23ImplicitCount else b.fields23ImplicitCount
, fields23Values = a.fields23Values <> b.fields23Values
, fields23Inner = case b.fields23Inner of { Nothing -> a.fields23Inner; x -> x }
, fields23Attrs = a.fields23Attrs <> b.fields23Attrs
, fields23Choice = case b.fields23Choice of { Nothing -> a.fields23Choice; x -> x }
, fields23AggregateImplicit = if b.fields23AggregateImplicit == 0 then a.fields23AggregateImplicit else b.fields23AggregateImplicit
, fields23UnknownFields = a.fields23UnknownFields <> b.fields23UnknownFields
}
instance Monoid Fields23 where
mempty = defaultFields23