Proto3 implicit field presence

57 Views Asked by At

In the proto3 guide (https://protobuf.dev/programming-guides/proto3/) it says:

If no explicit field label is applied, the default field label, called “implicit field presence,” is assumed. (You cannot explicitly set a field to this state.) A well-formed message can have zero or one of this field (but not more than one). You also cannot determine whether a field of this type was parsed from the wire. An implicit presence field will be serialized to the wire unless it is the default value. For more on this subject, see Field Presence.

but right underneath that they define a message like this:

message SearchRequest {
    string query = 1;
    int32 page_number = 2;
    int32 results_per_page = 3;
}

going by the above logic, shouldn't there be optional infront of two of these fields. And why should there be only one of this field type? Or is this meant differently?

0

There are 0 best solutions below