Protocol Buffers 3: Enumerations as Keys on a Map

Transfers cannot be used as keys on a card. PaxType is an enumeration here and is not permitted to be used as a key.

enum PaxType { ADULT = 0 ; CHILD = 1 ; INFANT = 2 ; } message FlightData { map<PaxType, FareType> fareType = 1; } 
+5
source share
1 answer

This is unacceptable because it does not work very well with open prum3 open semantics. For example, in Java, if you have a map, a key can be only one of certain values. If you manage to get the value of the enumeration key from the remote client / server that is not specified in the given value, it cannot be placed on the card. This restriction forces us either to discard a card with unknown enum keys (which contradicts the semantics of proto3 semantics), or to prohibit listing as card keys together.

for reference: https://groups.google.com/forum/#!topic/protobuf/ikeldBe60eI

+7
source

Source: https://habr.com/ru/post/1261247/


All Articles