diff --git a/.changelog/unreleased/features/200-tendermint-rs-0.35.md b/.changelog/v0.43.0/breaking-changes/200-tendermint-rs-0.35.md similarity index 100% rename from .changelog/unreleased/features/200-tendermint-rs-0.35.md rename to .changelog/v0.43.0/breaking-changes/200-tendermint-rs-0.35.md diff --git a/.changelog/v0.43.0/breaking-changes/207-update-tonic.md b/.changelog/v0.43.0/breaking-changes/207-update-tonic.md new file mode 100644 index 00000000..844b80c4 --- /dev/null +++ b/.changelog/v0.43.0/breaking-changes/207-update-tonic.md @@ -0,0 +1,2 @@ +- Update `tonic` to v0.11 + ([\#207](https://github.com/cosmos/ibc-proto-rs/pull/207)) \ No newline at end of file diff --git a/.changelog/v0.43.0/summary.md b/.changelog/v0.43.0/summary.md new file mode 100644 index 00000000..8e9d174e --- /dev/null +++ b/.changelog/v0.43.0/summary.md @@ -0,0 +1 @@ +This release updates `tendermint-proto` to v0.35.0 and `tonic` to v0.11.0. diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index f93962bb..c047df97 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -44,7 +44,7 @@ jobs: command: fmt args: --all -- --check - clippy_all_features: + clippy-all-features: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -59,7 +59,7 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} args: --all-features --all-targets - clippy_no_default_features: + clippy-no-default-features: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -74,7 +74,7 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} args: --no-default-features - check_features_powerset: + check-each-feature: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -85,7 +85,7 @@ jobs: override: true - uses: taiki-e/install-action@cargo-hack - uses: Swatinem/rust-cache@v1 - - run: cargo hack check --feature-powerset --no-dev-deps + - run: cargo hack check --each-feature --no-dev-deps test-stable: runs-on: ubuntu-latest diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d39a708..6ee8b624 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,16 @@ # CHANGELOG +## v0.43.0 + +*April 22nd, 2024* + +This release updates `tendermint-proto` to v0.35.0 and `tonic` to v0.11.0. + +### BREAKING CHANGES + +- Update `tendermint-proto` to v0.35.0 ([\#200](https://github.com/cosmos/ibc-proto-rs/pull/200)) +- Update `tonic` to v0.11 ([\#207](https://github.com/cosmos/ibc-proto-rs/pull/207)) + ## v0.42.2 *March 14th, 2024* diff --git a/Cargo.toml b/Cargo.toml index 884366c5..146ad2ed 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ibc-proto" -version = "0.42.2" +version = "0.43.0" authors = ["Informal Systems "] edition = "2021" license = "Apache-2.0" @@ -30,11 +30,11 @@ all-features = true [dependencies] prost = { version = "0.12.3", default-features = false, features = ["prost-derive"] } bytes = { version = "1.2", default-features = false } -tonic = { version = "0.10", default-features = false, optional = true } +tonic = { version = "0.11", default-features = false, optional = true } serde = { version = "1.0", default-features = false, optional = true } schemars = { version = "0.8", optional = true } subtle-encoding = { version = "0.5", default-features = false } -base64 = { version = "0.21", default-features = false, features = ["alloc"] } +base64 = { version = "0.22", default-features = false, features = ["alloc"] } flex-error = { version = "0.4", default-features = false } ics23 = { version = "0.11.0", default-features = false } informalsystems-pbjson = { version = "0.7.0", optional = true, default-features = false } diff --git a/src/prost/google.protobuf.rs b/src/prost/google.protobuf.rs index a0dfa109..3f43790e 100644 --- a/src/prost/google.protobuf.rs +++ b/src/prost/google.protobuf.rs @@ -192,9 +192,9 @@ pub struct FileDescriptorProto { /// If `edition` is present, this value must be "editions". #[prost(string, optional, tag = "12")] pub syntax: ::core::option::Option<::prost::alloc::string::String>, - /// The edition of the proto file, which is an opaque string. - #[prost(string, optional, tag = "13")] - pub edition: ::core::option::Option<::prost::alloc::string::String>, + /// The edition of the proto file. + #[prost(enumeration = "Edition", optional, tag = "14")] + pub edition: ::core::option::Option, } impl ::prost::Name for FileDescriptorProto { const NAME: &'static str = "FileDescriptorProto"; @@ -294,7 +294,7 @@ pub struct ExtensionRangeOptions { #[prost(message, optional, tag = "50")] pub features: ::core::option::Option, /// The verification state of the range. - /// TODO(b/278783756): flip the default to DECLARATION once all empty ranges + /// TODO: flip the default to DECLARATION once all empty ranges /// are marked as UNVERIFIED. #[prost( enumeration = "extension_range_options::VerificationState", @@ -432,12 +432,12 @@ pub struct FieldDescriptorProto { /// If true, this is a proto3 "optional". When a proto3 field is optional, it /// tracks presence regardless of field type. /// - /// When proto3_optional is true, this field must be belong to a oneof to - /// signal to old proto3 clients that presence is tracked for this field. This - /// oneof is known as a "synthetic" oneof, and this field must be its sole - /// member (each proto3 optional field gets its own synthetic oneof). Synthetic - /// oneofs exist in the descriptor only, and do not generate any API. Synthetic - /// oneofs must be ordered after all "real" oneofs. + /// When proto3_optional is true, this field must belong to a oneof to signal + /// to old proto3 clients that presence is tracked for this field. This oneof + /// is known as a "synthetic" oneof, and this field must be its sole member + /// (each proto3 optional field gets its own synthetic oneof). Synthetic oneofs + /// exist in the descriptor only, and do not generate any API. Synthetic oneofs + /// must be ordered after all "real" oneofs. /// /// For message fields, proto3_optional doesn't create any semantic change, /// since non-repeated message fields always track presence. However it still @@ -484,9 +484,10 @@ pub mod field_descriptor_proto { Bool = 8, String = 9, /// Tag-delimited aggregate. - /// Group type is deprecated and not supported in proto3. However, Proto3 + /// Group type is deprecated and not supported after google.protobuf. However, Proto3 /// implementations should still be able to parse the group wire format and - /// treat group fields as unknown fields. + /// treat group fields as unknown fields. In Editions, the group wire format + /// can be enabled via the `message_encoding` feature. Group = 10, /// Length-delimited aggregate. Message = 11, @@ -568,8 +569,11 @@ pub mod field_descriptor_proto { pub enum Label { /// 0 is reserved for errors Optional = 1, - Required = 2, Repeated = 3, + /// The required label is only allowed in google.protobuf. In proto3 and Editions + /// it's explicitly prohibited. In Editions, the `field_presence` feature + /// can be used to get this behavior. + Required = 2, } impl Label { /// String value of the enum field names used in the ProtoBuf definition. @@ -579,16 +583,16 @@ pub mod field_descriptor_proto { pub fn as_str_name(&self) -> &'static str { match self { Label::Optional => "LABEL_OPTIONAL", - Label::Required => "LABEL_REQUIRED", Label::Repeated => "LABEL_REPEATED", + Label::Required => "LABEL_REQUIRED", } } /// Creates an enum from field names used in the ProtoBuf definition. pub fn from_str_name(value: &str) -> ::core::option::Option { match value { "LABEL_OPTIONAL" => Some(Self::Optional), - "LABEL_REQUIRED" => Some(Self::Required), "LABEL_REPEATED" => Some(Self::Repeated), + "LABEL_REQUIRED" => Some(Self::Required), _ => None, } } @@ -802,8 +806,6 @@ pub struct FileOptions { pub java_generic_services: ::core::option::Option, #[prost(bool, optional, tag = "18", default = "false")] pub py_generic_services: ::core::option::Option, - #[prost(bool, optional, tag = "42", default = "false")] - pub php_generic_services: ::core::option::Option, /// Is this file deprecated? /// Depending on the target platform, this can emit Deprecated annotations /// for everything in the file, or it will be completely ignored; in the very @@ -943,10 +945,6 @@ pub struct MessageOptions { /// this is a formalization for deprecating messages. #[prost(bool, optional, tag = "3", default = "false")] pub deprecated: ::core::option::Option, - /// NOTE: Do not set the option in .proto files. Always use the maps syntax - /// instead. The option should only be implicitly set by the proto compiler - /// parser. - /// /// Whether the message is an automatically generated map entry type for the /// maps field. /// @@ -964,6 +962,10 @@ pub struct MessageOptions { /// use a native map in the target language to hold the keys and values. /// The reflection APIs in such implementations still need to work as /// if the field is a repeated message field. + /// + /// NOTE: Do not set the option in .proto files. Always use the maps syntax + /// instead. The option should only be implicitly set by the proto compiler + /// parser. #[prost(bool, optional, tag = "7")] pub map_entry: ::core::option::Option, /// Enable the legacy handling of JSON field name conflicts. This lowercases @@ -974,7 +976,7 @@ pub struct MessageOptions { /// This should only be used as a temporary measure against broken builds due /// to the change in behavior for JSON field name conflicts. /// - /// TODO(b/261750190) This is legacy behavior we plan to remove once downstream + /// TODO This is legacy behavior we plan to remove once downstream /// teams have had time to migrate. #[deprecated] #[prost(bool, optional, tag = "11")] @@ -1013,7 +1015,9 @@ pub struct FieldOptions { /// a more efficient representation on the wire. Rather than repeatedly /// writing the tag and type for each element, the entire array is encoded as /// a single length-delimited blob. In proto3, only explicit setting it to - /// false will avoid using packed encoding. + /// false will avoid using packed encoding. This option is prohibited in + /// Editions, but the `repeated_field_encoding` feature can be used to control + /// the behavior. #[prost(bool, optional, tag = "2")] pub packed: ::core::option::Option, /// The jstype option determines the JavaScript type used for values of the @@ -1051,19 +1055,11 @@ pub struct FieldOptions { /// call from multiple threads concurrently, while non-const methods continue /// to require exclusive access. /// - /// Note that implementations may choose not to check required fields within - /// a lazy sub-message. That is, calling IsInitialized() on the outer message - /// may return true even if the inner message has missing required fields. - /// This is necessary because otherwise the inner message would have to be - /// parsed in order to perform the check, defeating the purpose of lazy - /// parsing. An implementation which chooses not to check required fields - /// must be consistent about it. That is, for any particular sub-message, the - /// implementation must either *always* check its required fields, or *never* - /// check its required fields, regardless of whether or not the message has - /// been parsed. - /// - /// As of May 2022, lazy verifies the contents of the byte stream during - /// parsing. An invalid byte stream will cause the overall parsing to fail. + /// Note that lazy message fields are still eagerly verified to check + /// ill-formed wireformat or missing required fields. Calling IsInitialized() + /// on the outer message would fail if the inner message has missing required + /// fields. Failed verification would result in parsing failure (except when + /// uninitialized messages are acceptable). #[prost(bool, optional, tag = "5", default = "false")] pub lazy: ::core::option::Option, /// unverified_lazy does no correctness checks on the byte stream. This should @@ -1107,8 +1103,8 @@ pub mod field_options { #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct EditionDefault { - #[prost(string, optional, tag = "1")] - pub edition: ::core::option::Option<::prost::alloc::string::String>, + #[prost(enumeration = "super::Edition", optional, tag = "3")] + pub edition: ::core::option::Option, /// Textproto value. #[prost(string, optional, tag = "2")] pub value: ::core::option::Option<::prost::alloc::string::String>, @@ -1358,7 +1354,7 @@ pub struct EnumOptions { /// and strips underscored from the fields before comparison in proto3 only. /// The new behavior takes `json_name` into account and applies to proto2 as /// well. - /// TODO(b/261750190) Remove this legacy behavior once downstream teams have + /// TODO Remove this legacy behavior once downstream teams have /// had time to migrate. #[deprecated] #[prost(bool, optional, tag = "6")] @@ -1561,7 +1557,7 @@ impl ::prost::Name for UninterpretedOption { ::prost::alloc::format!("google.protobuf.{}", Self::NAME) } } -/// TODO(b/274655146) Enums in C++ gencode (and potentially other languages) are +/// TODO Enums in C++ gencode (and potentially other languages) are /// not well scoped. This means that each of the feature enums below can clash /// with each other. The short names we've chosen maximize call-site /// readability, but leave us very open to this scenario. A future feature will @@ -1576,14 +1572,12 @@ pub struct FeatureSet { pub enum_type: ::core::option::Option, #[prost(enumeration = "feature_set::RepeatedFieldEncoding", optional, tag = "3")] pub repeated_field_encoding: ::core::option::Option, - #[prost(enumeration = "feature_set::StringFieldValidation", optional, tag = "4")] - pub string_field_validation: ::core::option::Option, + #[prost(enumeration = "feature_set::Utf8Validation", optional, tag = "4")] + pub utf8_validation: ::core::option::Option, #[prost(enumeration = "feature_set::MessageEncoding", optional, tag = "5")] pub message_encoding: ::core::option::Option, #[prost(enumeration = "feature_set::JsonFormat", optional, tag = "6")] pub json_format: ::core::option::Option, - #[prost(message, optional, boxed, tag = "999")] - pub raw_features: ::core::option::Option<::prost::alloc::boxed::Box>, } /// Nested message and enum types in `FeatureSet`. pub mod feature_set { @@ -1719,31 +1713,28 @@ pub mod feature_set { ::prost::Enumeration )] #[repr(i32)] - pub enum StringFieldValidation { + pub enum Utf8Validation { Unknown = 0, - Mandatory = 1, - Hint = 2, + Verify = 2, None = 3, } - impl StringFieldValidation { + impl Utf8Validation { /// String value of the enum field names used in the ProtoBuf definition. /// /// The values are not transformed in any way and thus are considered stable /// (if the ProtoBuf definition does not change) and safe for programmatic use. pub fn as_str_name(&self) -> &'static str { match self { - StringFieldValidation::Unknown => "STRING_FIELD_VALIDATION_UNKNOWN", - StringFieldValidation::Mandatory => "MANDATORY", - StringFieldValidation::Hint => "HINT", - StringFieldValidation::None => "NONE", + Utf8Validation::Unknown => "UTF8_VALIDATION_UNKNOWN", + Utf8Validation::Verify => "VERIFY", + Utf8Validation::None => "NONE", } } /// Creates an enum from field names used in the ProtoBuf definition. pub fn from_str_name(value: &str) -> ::core::option::Option { match value { - "STRING_FIELD_VALIDATION_UNKNOWN" => Some(Self::Unknown), - "MANDATORY" => Some(Self::Mandatory), - "HINT" => Some(Self::Hint), + "UTF8_VALIDATION_UNKNOWN" => Some(Self::Unknown), + "VERIFY" => Some(Self::Verify), "NONE" => Some(Self::None), _ => None, } @@ -1835,6 +1826,55 @@ impl ::prost::Name for FeatureSet { ::prost::alloc::format!("google.protobuf.{}", Self::NAME) } } +/// A compiled specification for the defaults of a set of features. These +/// messages are generated from FeatureSet extensions and can be used to seed +/// feature resolution. The resolution with this object becomes a simple search +/// for the closest matching edition, followed by proto merges. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct FeatureSetDefaults { + #[prost(message, repeated, tag = "1")] + pub defaults: ::prost::alloc::vec::Vec< + feature_set_defaults::FeatureSetEditionDefault, + >, + /// The minimum supported edition (inclusive) when this was constructed. + /// Editions before this will not have defaults. + #[prost(enumeration = "Edition", optional, tag = "4")] + pub minimum_edition: ::core::option::Option, + /// The maximum known edition (inclusive) when this was constructed. Editions + /// after this will not have reliable defaults. + #[prost(enumeration = "Edition", optional, tag = "5")] + pub maximum_edition: ::core::option::Option, +} +/// Nested message and enum types in `FeatureSetDefaults`. +pub mod feature_set_defaults { + /// A map from every known edition with a unique set of defaults to its + /// defaults. Not all editions may be contained here. For a given edition, + /// the defaults at the closest matching edition ordered at or before it should + /// be used. This field must be in strict ascending order by edition. + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct FeatureSetEditionDefault { + #[prost(enumeration = "super::Edition", optional, tag = "3")] + pub edition: ::core::option::Option, + #[prost(message, optional, tag = "2")] + pub features: ::core::option::Option, + } + impl ::prost::Name for FeatureSetEditionDefault { + const NAME: &'static str = "FeatureSetEditionDefault"; + const PACKAGE: &'static str = "google.protobuf"; + fn full_name() -> ::prost::alloc::string::String { + ::prost::alloc::format!("google.protobuf.FeatureSetDefaults.{}", Self::NAME) + } + } +} +impl ::prost::Name for FeatureSetDefaults { + const NAME: &'static str = "FeatureSetDefaults"; + const PACKAGE: &'static str = "google.protobuf"; + fn full_name() -> ::prost::alloc::string::String { + ::prost::alloc::format!("google.protobuf.{}", Self::NAME) + } +} /// Encapsulates information about the original source file from which a /// FileDescriptorProto was generated. #[allow(clippy::derive_partial_eq_without_eq)] @@ -1895,7 +1935,7 @@ pub mod source_code_info { /// location. /// /// Each element is a field number or an index. They form a path from - /// the root FileDescriptorProto to the place where the definition occurs. + /// the root FileDescriptorProto to the place where the definition appears. /// For example, this path: /// \[ 4, 3, 2, 7, 1 \] /// refers to: @@ -2091,6 +2131,73 @@ impl ::prost::Name for GeneratedCodeInfo { ::prost::alloc::format!("google.protobuf.{}", Self::NAME) } } +/// The full set of known editions. +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] +#[repr(i32)] +pub enum Edition { + /// A placeholder for an unknown edition value. + Unknown = 0, + /// Legacy syntax "editions". These pre-date editions, but behave much like + /// distinct editions. These can't be used to specify the edition of proto + /// files, but feature definitions must supply proto2/proto3 defaults for + /// backwards compatibility. + Proto2 = 998, + Proto3 = 999, + /// Editions that have been released. The specific values are arbitrary and + /// should not be depended on, but they will always be time-ordered for easy + /// comparison. + Edition2023 = 1000, + Edition2024 = 1001, + /// Placeholder editions for testing feature resolution. These should not be + /// used or relyed on outside of tests. + Edition1TestOnly = 1, + Edition2TestOnly = 2, + Edition99997TestOnly = 99997, + Edition99998TestOnly = 99998, + Edition99999TestOnly = 99999, + /// Placeholder for specifying unbounded edition support. This should only + /// ever be used by plugins that can expect to never require any changes to + /// support a new edition. + Max = 2147483647, +} +impl Edition { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + Edition::Unknown => "EDITION_UNKNOWN", + Edition::Proto2 => "EDITION_PROTO2", + Edition::Proto3 => "EDITION_PROTO3", + Edition::Edition2023 => "EDITION_2023", + Edition::Edition2024 => "EDITION_2024", + Edition::Edition1TestOnly => "EDITION_1_TEST_ONLY", + Edition::Edition2TestOnly => "EDITION_2_TEST_ONLY", + Edition::Edition99997TestOnly => "EDITION_99997_TEST_ONLY", + Edition::Edition99998TestOnly => "EDITION_99998_TEST_ONLY", + Edition::Edition99999TestOnly => "EDITION_99999_TEST_ONLY", + Edition::Max => "EDITION_MAX", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "EDITION_UNKNOWN" => Some(Self::Unknown), + "EDITION_PROTO2" => Some(Self::Proto2), + "EDITION_PROTO3" => Some(Self::Proto3), + "EDITION_2023" => Some(Self::Edition2023), + "EDITION_2024" => Some(Self::Edition2024), + "EDITION_1_TEST_ONLY" => Some(Self::Edition1TestOnly), + "EDITION_2_TEST_ONLY" => Some(Self::Edition2TestOnly), + "EDITION_99997_TEST_ONLY" => Some(Self::Edition99997TestOnly), + "EDITION_99998_TEST_ONLY" => Some(Self::Edition99998TestOnly), + "EDITION_99999_TEST_ONLY" => Some(Self::Edition99999TestOnly), + "EDITION_MAX" => Some(Self::Max), + _ => None, + } + } +} /// A Timestamp represents a point in time independent of any time zone or local /// calendar, encoded as a count of seconds and fractions of seconds at /// nanosecond resolution. The count is relative to an epoch at UTC midnight on diff --git a/src/prost/google.protobuf.serde.rs b/src/prost/google.protobuf.serde.rs index 0c8064dd..4a8362c6 100644 --- a/src/prost/google.protobuf.serde.rs +++ b/src/prost/google.protobuf.serde.rs @@ -714,6 +714,104 @@ impl<'de> serde::Deserialize<'de> for Duration { deserializer.deserialize_struct("google.protobuf.Duration", FIELDS, GeneratedVisitor) } } +impl serde::Serialize for Edition { + #[allow(deprecated)] + fn serialize(&self, serializer: S) -> core::result::Result + where + S: serde::Serializer, + { + let variant = match self { + Self::Unknown => "EDITION_UNKNOWN", + Self::Proto2 => "EDITION_PROTO2", + Self::Proto3 => "EDITION_PROTO3", + Self::Edition2023 => "EDITION_2023", + Self::Edition2024 => "EDITION_2024", + Self::Edition1TestOnly => "EDITION_1_TEST_ONLY", + Self::Edition2TestOnly => "EDITION_2_TEST_ONLY", + Self::Edition99997TestOnly => "EDITION_99997_TEST_ONLY", + Self::Edition99998TestOnly => "EDITION_99998_TEST_ONLY", + Self::Edition99999TestOnly => "EDITION_99999_TEST_ONLY", + Self::Max => "EDITION_MAX", + }; + serializer.serialize_str(variant) + } +} +impl<'de> serde::Deserialize<'de> for Edition { + #[allow(deprecated)] + fn deserialize(deserializer: D) -> core::result::Result + where + D: serde::Deserializer<'de>, + { + const FIELDS: &[&str] = &[ + "EDITION_UNKNOWN", + "EDITION_PROTO2", + "EDITION_PROTO3", + "EDITION_2023", + "EDITION_2024", + "EDITION_1_TEST_ONLY", + "EDITION_2_TEST_ONLY", + "EDITION_99997_TEST_ONLY", + "EDITION_99998_TEST_ONLY", + "EDITION_99999_TEST_ONLY", + "EDITION_MAX", + ]; + + struct GeneratedVisitor; + + impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { + type Value = Edition; + + fn expecting(&self, formatter: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + write!(formatter, "expected one of: {:?}", &FIELDS) + } + + fn visit_i64(self, v: i64) -> core::result::Result + where + E: serde::de::Error, + { + i32::try_from(v) + .ok() + .and_then(|x| x.try_into().ok()) + .ok_or_else(|| { + serde::de::Error::invalid_value(serde::de::Unexpected::Signed(v), &self) + }) + } + + fn visit_u64(self, v: u64) -> core::result::Result + where + E: serde::de::Error, + { + i32::try_from(v) + .ok() + .and_then(|x| x.try_into().ok()) + .ok_or_else(|| { + serde::de::Error::invalid_value(serde::de::Unexpected::Unsigned(v), &self) + }) + } + + fn visit_str(self, value: &str) -> core::result::Result + where + E: serde::de::Error, + { + match value { + "EDITION_UNKNOWN" => Ok(Edition::Unknown), + "EDITION_PROTO2" => Ok(Edition::Proto2), + "EDITION_PROTO3" => Ok(Edition::Proto3), + "EDITION_2023" => Ok(Edition::Edition2023), + "EDITION_2024" => Ok(Edition::Edition2024), + "EDITION_1_TEST_ONLY" => Ok(Edition::Edition1TestOnly), + "EDITION_2_TEST_ONLY" => Ok(Edition::Edition2TestOnly), + "EDITION_99997_TEST_ONLY" => Ok(Edition::Edition99997TestOnly), + "EDITION_99998_TEST_ONLY" => Ok(Edition::Edition99998TestOnly), + "EDITION_99999_TEST_ONLY" => Ok(Edition::Edition99999TestOnly), + "EDITION_MAX" => Ok(Edition::Max), + _ => Err(serde::de::Error::unknown_variant(value, FIELDS)), + } + } + } + deserializer.deserialize_any(GeneratedVisitor) + } +} impl serde::Serialize for EnumDescriptorProto { #[allow(deprecated)] fn serialize(&self, serializer: S) -> core::result::Result @@ -1824,9 +1922,6 @@ impl serde::Serialize for FeatureSet { if true { len += 1; } - if true { - len += 1; - } let mut struct_ser = serializer.serialize_struct("google.protobuf.FeatureSet", len)?; if let Some(v) = self.field_presence.as_ref() { let v = feature_set::FieldPresence::try_from(*v) @@ -1843,10 +1938,10 @@ impl serde::Serialize for FeatureSet { .map_err(|_| serde::ser::Error::custom(::alloc::format!("Invalid variant {}", *v)))?; struct_ser.serialize_field("repeatedFieldEncoding", &v)?; } - if let Some(v) = self.string_field_validation.as_ref() { - let v = feature_set::StringFieldValidation::try_from(*v) + if let Some(v) = self.utf8_validation.as_ref() { + let v = feature_set::Utf8Validation::try_from(*v) .map_err(|_| serde::ser::Error::custom(::alloc::format!("Invalid variant {}", *v)))?; - struct_ser.serialize_field("stringFieldValidation", &v)?; + struct_ser.serialize_field("utf8Validation", &v)?; } if let Some(v) = self.message_encoding.as_ref() { let v = feature_set::MessageEncoding::try_from(*v) @@ -1858,9 +1953,6 @@ impl serde::Serialize for FeatureSet { .map_err(|_| serde::ser::Error::custom(::alloc::format!("Invalid variant {}", *v)))?; struct_ser.serialize_field("jsonFormat", &v)?; } - if let Some(v) = self.raw_features.as_ref() { - struct_ser.serialize_field("rawFeatures", v)?; - } struct_ser.end() } } @@ -1877,14 +1969,12 @@ impl<'de> serde::Deserialize<'de> for FeatureSet { "enumType", "repeated_field_encoding", "repeatedFieldEncoding", - "string_field_validation", - "stringFieldValidation", + "utf8_validation", + "utf8Validation", "message_encoding", "messageEncoding", "json_format", "jsonFormat", - "raw_features", - "rawFeatures", ]; #[allow(clippy::enum_variant_names)] @@ -1892,10 +1982,9 @@ impl<'de> serde::Deserialize<'de> for FeatureSet { FieldPresence, EnumType, RepeatedFieldEncoding, - StringFieldValidation, + Utf8Validation, MessageEncoding, JsonFormat, - RawFeatures, } impl<'de> serde::Deserialize<'de> for GeneratedField { fn deserialize(deserializer: D) -> core::result::Result @@ -1920,10 +2009,9 @@ impl<'de> serde::Deserialize<'de> for FeatureSet { "fieldPresence" | "field_presence" => Ok(GeneratedField::FieldPresence), "enumType" | "enum_type" => Ok(GeneratedField::EnumType), "repeatedFieldEncoding" | "repeated_field_encoding" => Ok(GeneratedField::RepeatedFieldEncoding), - "stringFieldValidation" | "string_field_validation" => Ok(GeneratedField::StringFieldValidation), + "utf8Validation" | "utf8_validation" => Ok(GeneratedField::Utf8Validation), "messageEncoding" | "message_encoding" => Ok(GeneratedField::MessageEncoding), "jsonFormat" | "json_format" => Ok(GeneratedField::JsonFormat), - "rawFeatures" | "raw_features" => Ok(GeneratedField::RawFeatures), _ => Err(serde::de::Error::unknown_field(value, FIELDS)), } } @@ -1946,10 +2034,9 @@ impl<'de> serde::Deserialize<'de> for FeatureSet { let mut field_presence__ = None; let mut enum_type__ = None; let mut repeated_field_encoding__ = None; - let mut string_field_validation__ = None; + let mut utf8_validation__ = None; let mut message_encoding__ = None; let mut json_format__ = None; - let mut raw_features__ = None; while let Some(k) = map_.next_key()? { match k { GeneratedField::FieldPresence => { @@ -1970,11 +2057,11 @@ impl<'de> serde::Deserialize<'de> for FeatureSet { } repeated_field_encoding__ = map_.next_value::<::core::option::Option>()?.map(|x| x as i32); } - GeneratedField::StringFieldValidation => { - if string_field_validation__.is_some() { - return Err(serde::de::Error::duplicate_field("stringFieldValidation")); + GeneratedField::Utf8Validation => { + if utf8_validation__.is_some() { + return Err(serde::de::Error::duplicate_field("utf8Validation")); } - string_field_validation__ = map_.next_value::<::core::option::Option>()?.map(|x| x as i32); + utf8_validation__ = map_.next_value::<::core::option::Option>()?.map(|x| x as i32); } GeneratedField::MessageEncoding => { if message_encoding__.is_some() { @@ -1988,22 +2075,15 @@ impl<'de> serde::Deserialize<'de> for FeatureSet { } json_format__ = map_.next_value::<::core::option::Option>()?.map(|x| x as i32); } - GeneratedField::RawFeatures => { - if raw_features__.is_some() { - return Err(serde::de::Error::duplicate_field("rawFeatures")); - } - raw_features__ = map_.next_value()?; - } } } Ok(FeatureSet { field_presence: field_presence__, enum_type: enum_type__, repeated_field_encoding: repeated_field_encoding__, - string_field_validation: string_field_validation__, + utf8_validation: utf8_validation__, message_encoding: message_encoding__, json_format: json_format__, - raw_features: raw_features__, }) } } @@ -2383,38 +2463,36 @@ impl<'de> serde::Deserialize<'de> for feature_set::RepeatedFieldEncoding { deserializer.deserialize_any(GeneratedVisitor) } } -impl serde::Serialize for feature_set::StringFieldValidation { +impl serde::Serialize for feature_set::Utf8Validation { #[allow(deprecated)] fn serialize(&self, serializer: S) -> core::result::Result where S: serde::Serializer, { let variant = match self { - Self::Unknown => "STRING_FIELD_VALIDATION_UNKNOWN", - Self::Mandatory => "MANDATORY", - Self::Hint => "HINT", + Self::Unknown => "UTF8_VALIDATION_UNKNOWN", + Self::Verify => "VERIFY", Self::None => "NONE", }; serializer.serialize_str(variant) } } -impl<'de> serde::Deserialize<'de> for feature_set::StringFieldValidation { +impl<'de> serde::Deserialize<'de> for feature_set::Utf8Validation { #[allow(deprecated)] fn deserialize(deserializer: D) -> core::result::Result where D: serde::Deserializer<'de>, { const FIELDS: &[&str] = &[ - "STRING_FIELD_VALIDATION_UNKNOWN", - "MANDATORY", - "HINT", + "UTF8_VALIDATION_UNKNOWN", + "VERIFY", "NONE", ]; struct GeneratedVisitor; impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { - type Value = feature_set::StringFieldValidation; + type Value = feature_set::Utf8Validation; fn expecting(&self, formatter: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { write!(formatter, "expected one of: {:?}", &FIELDS) @@ -2449,10 +2527,9 @@ impl<'de> serde::Deserialize<'de> for feature_set::StringFieldValidation { E: serde::de::Error, { match value { - "STRING_FIELD_VALIDATION_UNKNOWN" => Ok(feature_set::StringFieldValidation::Unknown), - "MANDATORY" => Ok(feature_set::StringFieldValidation::Mandatory), - "HINT" => Ok(feature_set::StringFieldValidation::Hint), - "NONE" => Ok(feature_set::StringFieldValidation::None), + "UTF8_VALIDATION_UNKNOWN" => Ok(feature_set::Utf8Validation::Unknown), + "VERIFY" => Ok(feature_set::Utf8Validation::Verify), + "NONE" => Ok(feature_set::Utf8Validation::None), _ => Err(serde::de::Error::unknown_variant(value, FIELDS)), } } @@ -2460,6 +2537,247 @@ impl<'de> serde::Deserialize<'de> for feature_set::StringFieldValidation { deserializer.deserialize_any(GeneratedVisitor) } } +impl serde::Serialize for FeatureSetDefaults { + #[allow(deprecated)] + fn serialize(&self, serializer: S) -> core::result::Result + where + S: serde::Serializer, + { + use serde::ser::SerializeStruct; + let mut len = 0; + if true { + len += 1; + } + if true { + len += 1; + } + if true { + len += 1; + } + let mut struct_ser = serializer.serialize_struct("google.protobuf.FeatureSetDefaults", len)?; + if true { + struct_ser.serialize_field("defaults", &self.defaults)?; + } + if let Some(v) = self.minimum_edition.as_ref() { + let v = Edition::try_from(*v) + .map_err(|_| serde::ser::Error::custom(::alloc::format!("Invalid variant {}", *v)))?; + struct_ser.serialize_field("minimumEdition", &v)?; + } + if let Some(v) = self.maximum_edition.as_ref() { + let v = Edition::try_from(*v) + .map_err(|_| serde::ser::Error::custom(::alloc::format!("Invalid variant {}", *v)))?; + struct_ser.serialize_field("maximumEdition", &v)?; + } + struct_ser.end() + } +} +impl<'de> serde::Deserialize<'de> for FeatureSetDefaults { + #[allow(deprecated)] + fn deserialize(deserializer: D) -> core::result::Result + where + D: serde::Deserializer<'de>, + { + const FIELDS: &[&str] = &[ + "defaults", + "minimum_edition", + "minimumEdition", + "maximum_edition", + "maximumEdition", + ]; + + #[allow(clippy::enum_variant_names)] + enum GeneratedField { + Defaults, + MinimumEdition, + MaximumEdition, + } + impl<'de> serde::Deserialize<'de> for GeneratedField { + fn deserialize(deserializer: D) -> core::result::Result + where + D: serde::Deserializer<'de>, + { + struct GeneratedVisitor; + + impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { + type Value = GeneratedField; + + fn expecting(&self, formatter: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + write!(formatter, "expected one of: {:?}", &FIELDS) + } + + #[allow(unused_variables)] + fn visit_str(self, value: &str) -> core::result::Result + where + E: serde::de::Error, + { + match value { + "defaults" => Ok(GeneratedField::Defaults), + "minimumEdition" | "minimum_edition" => Ok(GeneratedField::MinimumEdition), + "maximumEdition" | "maximum_edition" => Ok(GeneratedField::MaximumEdition), + _ => Err(serde::de::Error::unknown_field(value, FIELDS)), + } + } + } + deserializer.deserialize_identifier(GeneratedVisitor) + } + } + struct GeneratedVisitor; + impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { + type Value = FeatureSetDefaults; + + fn expecting(&self, formatter: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + formatter.write_str("struct google.protobuf.FeatureSetDefaults") + } + + fn visit_map(self, mut map_: V) -> core::result::Result + where + V: serde::de::MapAccess<'de>, + { + let mut defaults__ = None; + let mut minimum_edition__ = None; + let mut maximum_edition__ = None; + while let Some(k) = map_.next_key()? { + match k { + GeneratedField::Defaults => { + if defaults__.is_some() { + return Err(serde::de::Error::duplicate_field("defaults")); + } + defaults__ = Some(map_.next_value()?); + } + GeneratedField::MinimumEdition => { + if minimum_edition__.is_some() { + return Err(serde::de::Error::duplicate_field("minimumEdition")); + } + minimum_edition__ = map_.next_value::<::core::option::Option>()?.map(|x| x as i32); + } + GeneratedField::MaximumEdition => { + if maximum_edition__.is_some() { + return Err(serde::de::Error::duplicate_field("maximumEdition")); + } + maximum_edition__ = map_.next_value::<::core::option::Option>()?.map(|x| x as i32); + } + } + } + Ok(FeatureSetDefaults { + defaults: defaults__.unwrap_or_default(), + minimum_edition: minimum_edition__, + maximum_edition: maximum_edition__, + }) + } + } + deserializer.deserialize_struct("google.protobuf.FeatureSetDefaults", FIELDS, GeneratedVisitor) + } +} +impl serde::Serialize for feature_set_defaults::FeatureSetEditionDefault { + #[allow(deprecated)] + fn serialize(&self, serializer: S) -> core::result::Result + where + S: serde::Serializer, + { + use serde::ser::SerializeStruct; + let mut len = 0; + if true { + len += 1; + } + if true { + len += 1; + } + let mut struct_ser = serializer.serialize_struct("google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault", len)?; + if let Some(v) = self.edition.as_ref() { + let v = Edition::try_from(*v) + .map_err(|_| serde::ser::Error::custom(::alloc::format!("Invalid variant {}", *v)))?; + struct_ser.serialize_field("edition", &v)?; + } + if let Some(v) = self.features.as_ref() { + struct_ser.serialize_field("features", v)?; + } + struct_ser.end() + } +} +impl<'de> serde::Deserialize<'de> for feature_set_defaults::FeatureSetEditionDefault { + #[allow(deprecated)] + fn deserialize(deserializer: D) -> core::result::Result + where + D: serde::Deserializer<'de>, + { + const FIELDS: &[&str] = &[ + "edition", + "features", + ]; + + #[allow(clippy::enum_variant_names)] + enum GeneratedField { + Edition, + Features, + } + impl<'de> serde::Deserialize<'de> for GeneratedField { + fn deserialize(deserializer: D) -> core::result::Result + where + D: serde::Deserializer<'de>, + { + struct GeneratedVisitor; + + impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { + type Value = GeneratedField; + + fn expecting(&self, formatter: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + write!(formatter, "expected one of: {:?}", &FIELDS) + } + + #[allow(unused_variables)] + fn visit_str(self, value: &str) -> core::result::Result + where + E: serde::de::Error, + { + match value { + "edition" => Ok(GeneratedField::Edition), + "features" => Ok(GeneratedField::Features), + _ => Err(serde::de::Error::unknown_field(value, FIELDS)), + } + } + } + deserializer.deserialize_identifier(GeneratedVisitor) + } + } + struct GeneratedVisitor; + impl<'de> serde::de::Visitor<'de> for GeneratedVisitor { + type Value = feature_set_defaults::FeatureSetEditionDefault; + + fn expecting(&self, formatter: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + formatter.write_str("struct google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault") + } + + fn visit_map(self, mut map_: V) -> core::result::Result + where + V: serde::de::MapAccess<'de>, + { + let mut edition__ = None; + let mut features__ = None; + while let Some(k) = map_.next_key()? { + match k { + GeneratedField::Edition => { + if edition__.is_some() { + return Err(serde::de::Error::duplicate_field("edition")); + } + edition__ = map_.next_value::<::core::option::Option>()?.map(|x| x as i32); + } + GeneratedField::Features => { + if features__.is_some() { + return Err(serde::de::Error::duplicate_field("features")); + } + features__ = map_.next_value()?; + } + } + } + Ok(feature_set_defaults::FeatureSetEditionDefault { + edition: edition__, + features: features__, + }) + } + } + deserializer.deserialize_struct("google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault", FIELDS, GeneratedVisitor) + } +} impl serde::Serialize for FieldDescriptorProto { #[allow(deprecated)] fn serialize(&self, serializer: S) -> core::result::Result @@ -2742,8 +3060,8 @@ impl serde::Serialize for field_descriptor_proto::Label { { let variant = match self { Self::Optional => "LABEL_OPTIONAL", - Self::Required => "LABEL_REQUIRED", Self::Repeated => "LABEL_REPEATED", + Self::Required => "LABEL_REQUIRED", }; serializer.serialize_str(variant) } @@ -2756,8 +3074,8 @@ impl<'de> serde::Deserialize<'de> for field_descriptor_proto::Label { { const FIELDS: &[&str] = &[ "LABEL_OPTIONAL", - "LABEL_REQUIRED", "LABEL_REPEATED", + "LABEL_REQUIRED", ]; struct GeneratedVisitor; @@ -2799,8 +3117,8 @@ impl<'de> serde::Deserialize<'de> for field_descriptor_proto::Label { { match value { "LABEL_OPTIONAL" => Ok(field_descriptor_proto::Label::Optional), - "LABEL_REQUIRED" => Ok(field_descriptor_proto::Label::Required), "LABEL_REPEATED" => Ok(field_descriptor_proto::Label::Repeated), + "LABEL_REQUIRED" => Ok(field_descriptor_proto::Label::Required), _ => Err(serde::de::Error::unknown_variant(value, FIELDS)), } } @@ -3326,7 +3644,9 @@ impl serde::Serialize for field_options::EditionDefault { } let mut struct_ser = serializer.serialize_struct("google.protobuf.FieldOptions.EditionDefault", len)?; if let Some(v) = self.edition.as_ref() { - struct_ser.serialize_field("edition", v)?; + let v = Edition::try_from(*v) + .map_err(|_| serde::ser::Error::custom(::alloc::format!("Invalid variant {}", *v)))?; + struct_ser.serialize_field("edition", &v)?; } if let Some(v) = self.value.as_ref() { struct_ser.serialize_field("value", v)?; @@ -3399,7 +3719,7 @@ impl<'de> serde::Deserialize<'de> for field_options::EditionDefault { if edition__.is_some() { return Err(serde::de::Error::duplicate_field("edition")); } - edition__ = map_.next_value()?; + edition__ = map_.next_value::<::core::option::Option>()?.map(|x| x as i32); } GeneratedField::Value => { if value__.is_some() { @@ -3746,7 +4066,9 @@ impl serde::Serialize for FileDescriptorProto { struct_ser.serialize_field("syntax", v)?; } if let Some(v) = self.edition.as_ref() { - struct_ser.serialize_field("edition", v)?; + let v = Edition::try_from(*v) + .map_err(|_| serde::ser::Error::custom(::alloc::format!("Invalid variant {}", *v)))?; + struct_ser.serialize_field("edition", &v)?; } struct_ser.end() } @@ -3943,7 +4265,7 @@ impl<'de> serde::Deserialize<'de> for FileDescriptorProto { if edition__.is_some() { return Err(serde::de::Error::duplicate_field("edition")); } - edition__ = map_.next_value()?; + edition__ = map_.next_value::<::core::option::Option>()?.map(|x| x as i32); } } } @@ -4129,9 +4451,6 @@ impl serde::Serialize for FileOptions { if true { len += 1; } - if true { - len += 1; - } let mut struct_ser = serializer.serialize_struct("google.protobuf.FileOptions", len)?; if let Some(v) = self.java_package.as_ref() { struct_ser.serialize_field("javaPackage", v)?; @@ -4165,9 +4484,6 @@ impl serde::Serialize for FileOptions { if let Some(v) = self.py_generic_services.as_ref() { struct_ser.serialize_field("pyGenericServices", v)?; } - if let Some(v) = self.php_generic_services.as_ref() { - struct_ser.serialize_field("phpGenericServices", v)?; - } if let Some(v) = self.deprecated.as_ref() { struct_ser.serialize_field("deprecated", v)?; } @@ -4231,8 +4547,6 @@ impl<'de> serde::Deserialize<'de> for FileOptions { "javaGenericServices", "py_generic_services", "pyGenericServices", - "php_generic_services", - "phpGenericServices", "deprecated", "cc_enable_arenas", "ccEnableArenas", @@ -4267,7 +4581,6 @@ impl<'de> serde::Deserialize<'de> for FileOptions { CcGenericServices, JavaGenericServices, PyGenericServices, - PhpGenericServices, Deprecated, CcEnableArenas, ObjcClassPrefix, @@ -4310,7 +4623,6 @@ impl<'de> serde::Deserialize<'de> for FileOptions { "ccGenericServices" | "cc_generic_services" => Ok(GeneratedField::CcGenericServices), "javaGenericServices" | "java_generic_services" => Ok(GeneratedField::JavaGenericServices), "pyGenericServices" | "py_generic_services" => Ok(GeneratedField::PyGenericServices), - "phpGenericServices" | "php_generic_services" => Ok(GeneratedField::PhpGenericServices), "deprecated" => Ok(GeneratedField::Deprecated), "ccEnableArenas" | "cc_enable_arenas" => Ok(GeneratedField::CcEnableArenas), "objcClassPrefix" | "objc_class_prefix" => Ok(GeneratedField::ObjcClassPrefix), @@ -4351,7 +4663,6 @@ impl<'de> serde::Deserialize<'de> for FileOptions { let mut cc_generic_services__ = None; let mut java_generic_services__ = None; let mut py_generic_services__ = None; - let mut php_generic_services__ = None; let mut deprecated__ = None; let mut cc_enable_arenas__ = None; let mut objc_class_prefix__ = None; @@ -4425,12 +4736,6 @@ impl<'de> serde::Deserialize<'de> for FileOptions { } py_generic_services__ = map_.next_value()?; } - GeneratedField::PhpGenericServices => { - if php_generic_services__.is_some() { - return Err(serde::de::Error::duplicate_field("phpGenericServices")); - } - php_generic_services__ = map_.next_value()?; - } GeneratedField::Deprecated => { if deprecated__.is_some() { return Err(serde::de::Error::duplicate_field("deprecated")); @@ -4510,7 +4815,6 @@ impl<'de> serde::Deserialize<'de> for FileOptions { cc_generic_services: cc_generic_services__, java_generic_services: java_generic_services__, py_generic_services: py_generic_services__, - php_generic_services: php_generic_services__, deprecated: deprecated__, cc_enable_arenas: cc_enable_arenas__, objc_class_prefix: objc_class_prefix__, diff --git a/src/prost/proto_descriptor.bin b/src/prost/proto_descriptor.bin index e61b7875..a358d97c 100644 Binary files a/src/prost/proto_descriptor.bin and b/src/prost/proto_descriptor.bin differ