// Protocol Buffers for Rust with Gadgets // // Note: While proto3 still supports extensions for custom fields (https://github.com/protocolbuffers/protobuf/issues/1460) // it does not support default values. Unfortunately the OneOfOptions::nullable field has a default value of true, while // in proto3 booleans have a default value of false. We can't migrate this file to proto3 without deprecating nullable // and changing its semantics. syntax = "proto2"; package rust; import "google/protobuf/descriptor.proto"; extend google.protobuf.FieldOptions { // Generate this field in a Box as opposed to inline Option optional bool box_it = 50000; // Generates a `Lazy` optional bool grpc_slices = 50003; // Generates a `Lazy` optional bool blob = 50010; // Use a different Rust type which implements `pb::Message` to represent the field. // All paths must be fully qualified, as in `::my_crate::full::path::to::type`. // This only works with proto3. optional string type = 50004; // Generate this `bytes` field using a Lazy to enable zero-copy deserialization. optional bool zero_copy = 50007; // Generate this `string` field using a type that supports a small string optimization. optional bool sso = 50009; // If false, make this field's Rust type non-Optional. If the field is // missing on the wire during deserialization, it will remain as // Default::default(). // // It doesn't make sense to specify this option for a repeating field, as a // missing field always deserializes as an empty Vec. // In proto3, this option is also ignored for non-`optional` primitive types, // which are already non-nullable. // // Beware that Default may not make sense for all message types. In // particular, fields using `OneofOptions.nullable=false` or // `EnumOptions.err_if_default_or_unknown=true` will simply default to their // first variant, and will _not_ trigger a deserialization error. That // behaviour may change in the future (TODO). optional bool nullable_field = 50008 [default=true]; } extend google.protobuf.EnumOptions { // Setting this to true on an enum means the generated enum won't even have a value for the // 0-value, and any message that would've parsed to having the value be 0 fail instead. // // If an enum field doesn't appear in the wire format of proto3, the 0 value is assumed. So if // an enum field is added to a message in use between a client and server, and the client hasn't // been recompiled, then all received messages on the server side will get the 0 value. As such, // it's common in cases when there's not an obvious (and safe) default value to make the 0 value // an explicit unknown/invalid value. In those cases, they become cumbersome to use in Rust // because match statements will always require a branch for the unknown/invalid case, but it's // more desirable to just fail at parse time. If the client has updated *past* the server, it may // send a value that the server does not know how to handle. We *also* fail this at parse time. optional bool err_if_default_or_unknown = 50002; // Setting this to true means that an enum's variants are considered exhaustive. // A Rust `enum` will be generated, rather than a wrapper around `i32`. This // makes matching against the enum simpler as there is no need to match // unknown variants. Instead, deserialization will fail if an unknown // variant is found over the wire. That makes adding or removing variants // potentially unsafe when it comes to version skew. // // This option differs from `err_if_default_or_unknown` because default // values are still allowed. The two options are incompatible, as // `err_if_default_or_unknown` is strictly stronger. optional bool closed_enum = 50008; } extend google.protobuf.MessageOptions { // Setting this to true adds an extra field to the deserialized message, which includes // a serialized representation of unrecognized fields. // Eg. // MyMessage { // field: u32, // _unrecognized: Vec, // } optional bool preserve_unrecognized = 50006; } extend google.protobuf.OneofOptions { // If false, this oneof must have a field set. Parse error if no variant (or unrecognized // variant) is set. optional bool nullable = 50001 [default=true]; } extend google.protobuf.FileOptions { optional bool serde_derive = 50005 [default=false]; }