Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to define repeated field as required in google protocol buffer?

how to define repeated field as required in Google protocol buffer?I have a field that modifier is repeated(repeated int32 A ).How i add required modifier to this field? in fact i want to have both modifier(required and repeated).

like image 363
Mehdi Honarmand Avatar asked Jul 02 '15 06:07

Mehdi Honarmand


1 Answers

Sorry, there is no way to mark a repeated field as "required".

In fact, required itself is widely considered a misfeature and is being phased out in Protobuf 3.0. For an extended explanation/rant of why this is the case, see:

https://capnproto.org/faq.html#how-do-i-make-a-field-required-like-in-protocol-buffers

(That's a link to the Cap'n Proto web site, which is a competitor to Protobufs, but its author (namely, me) was also the main author of Protobuf v2.)

like image 74
Kenton Varda Avatar answered Sep 22 '22 05:09

Kenton Varda