diff --git a/buffa-build/src/lib.rs b/buffa-build/src/lib.rs index baa9fb3..b70c312 100644 --- a/buffa-build/src/lib.rs +++ b/buffa-build/src/lib.rs @@ -674,7 +674,7 @@ fn generate_include_file(entries: &[(String, String)], relative: bool) -> String #[derive(Default)] struct ModNode { files: Vec, - children: BTreeMap, + children: BTreeMap, } let mut root = ModNode::default(); diff --git a/buffa-codegen/src/impl_message.rs b/buffa-codegen/src/impl_message.rs index d795cb5..b9ea8b6 100644 --- a/buffa-codegen/src/impl_message.rs +++ b/buffa-codegen/src/impl_message.rs @@ -521,7 +521,7 @@ pub fn generate_message_impl( fn default_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox<#name_ident> = ::buffa::__private::OnceBox::new(); - VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(#name_ident::default())) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } diff --git a/buffa-codegen/src/imports.rs b/buffa-codegen/src/imports.rs index 66acf37..47b68b8 100644 --- a/buffa-codegen/src/imports.rs +++ b/buffa-codegen/src/imports.rs @@ -55,7 +55,7 @@ impl ImportResolver { blocked.insert(name.to_string()); } } - ImportResolver { blocked } + Self { blocked } } /// Emit the `use` block for the top of a generated file. diff --git a/buffa-codegen/src/lib.rs b/buffa-codegen/src/lib.rs index af9a158..3a8e019 100644 --- a/buffa-codegen/src/lib.rs +++ b/buffa-codegen/src/lib.rs @@ -242,7 +242,7 @@ pub fn generate_module_tree( #[derive(Default)] struct ModNode { files: Vec, - children: BTreeMap, + children: BTreeMap, } let mut root = ModNode::default(); diff --git a/buffa-codegen/src/message.rs b/buffa-codegen/src/message.rs index eb5b721..98836ae 100644 --- a/buffa-codegen/src/message.rs +++ b/buffa-codegen/src/message.rs @@ -886,6 +886,12 @@ fn is_value_field( #[derive(Debug)] struct FieldInfo { rust_type: TokenStream, + /// Type to use in the struct field declaration. Differs from `rust_type` + /// only for self-referential message fields, where it uses `Self` instead + /// of the concrete name. `rust_type` stays concrete for serde-deserialize + /// codegen, which runs inside a local Visitor impl where `Self` binds to + /// the wrong type. + struct_field_type: TokenStream, is_repeated: bool, is_map: bool, /// Whether this field has explicit presence and uses `Option` wrapping. @@ -984,6 +990,25 @@ fn classify_field( scalar_rust_type(field_type, resolver)? }; + // Self-referential struct fields (e.g. DescriptorProto.nested_type) can + // use `Self` in the struct declaration. Only message-typed, non-map + // fields qualify. `rust_type` stays concrete for the serde-deserialize + // path — that codegen runs inside `impl Visitor for _V` where `Self` + // means `_V`, not the message. + let self_fqn = format!(".{proto_fqn}"); + let is_self_ref = field.type_name.as_deref() == Some(self_fqn.as_str()) && !is_map; + let struct_field_type = if is_self_ref { + if is_repeated { + let vec = resolver.vec(); + quote! { #vec } + } else { + let mf = resolver.message_field(); + quote! { #mf } + } + } else { + rust_type.clone() + }; + let map_key_type = map_entry.and_then(|e| map_entry_key_type(ctx, e, features)); let map_value_type = map_entry.and_then(|e| map_entry_value_type(ctx, e, features)); @@ -1006,6 +1031,7 @@ fn classify_field( Ok(FieldInfo { rust_type, + struct_field_type, is_repeated, is_map, is_optional, @@ -1066,7 +1092,7 @@ fn generate_field( } else { quote! {} }; - let rust_type = &info.rust_type; + let rust_type = &info.struct_field_type; let tokens = quote! { #doc #serde_attr diff --git a/buffa-codegen/src/oneof.rs b/buffa-codegen/src/oneof.rs index 782da34..7494f78 100644 --- a/buffa-codegen/src/oneof.rs +++ b/buffa-codegen/src/oneof.rs @@ -200,7 +200,7 @@ pub fn generate_oneof_enum( let from_oneof = quote! { impl From<#ty> for #rust_enum_ident { fn from(v: #ty) -> Self { - #rust_enum_ident::#ident(::buffa::alloc::boxed::Box::new(v)) + Self::#ident(::buffa::alloc::boxed::Box::new(v)) } } }; @@ -213,7 +213,7 @@ pub fn generate_oneof_enum( quote! { impl From<#ty> for ::core::option::Option<#rust_enum_ident> { fn from(v: #ty) -> Self { - ::core::option::Option::Some(#rust_enum_ident::from(v)) + Self::Some(#rust_enum_ident::from(v)) } } } diff --git a/buffa-codegen/src/view.rs b/buffa-codegen/src/view.rs index c664b69..d5b2a7d 100644 --- a/buffa-codegen/src/view.rs +++ b/buffa-codegen/src/view.rs @@ -271,7 +271,7 @@ pub fn generate_view( static VALUE: ::buffa::__private::OnceBox<#view_ident<'static>> = ::buffa::__private::OnceBox::new(); VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new( - #view_ident::default(), + Self::default(), )) } } @@ -335,9 +335,25 @@ fn view_struct_field( view_singular_type(ctx, field, current_package, features)? }; + // Self-referential view fields (e.g. HttpRuleView.additional_bindings) + // can use `Self` — inside `struct FooView<'a>`, `Self` means `FooView<'a>` + // with the lifetime applied. Override only for message-typed, non-map + // struct fields; decode and to_owned paths use the resolved type as-is + // via the helper functions so no conflict there. + let self_fqn = format!(".{proto_fqn}"); + let struct_ty = if field.type_name.as_deref() == Some(self_fqn.as_str()) { + if is_repeated { + quote! { ::buffa::RepeatedView<'a, Self> } + } else { + quote! { ::buffa::MessageFieldView } + } + } else { + rust_type + }; + Ok(Some(quote! { #doc - pub #ident: #rust_type, + pub #ident: #struct_ty, })) } diff --git a/buffa-descriptor/src/generated/google.protobuf.compiler.plugin.rs b/buffa-descriptor/src/generated/google.protobuf.compiler.plugin.rs index c79758a..d714cb9 100644 --- a/buffa-descriptor/src/generated/google.protobuf.compiler.plugin.rs +++ b/buffa-descriptor/src/generated/google.protobuf.compiler.plugin.rs @@ -40,7 +40,7 @@ impl Version { unsafe impl ::buffa::DefaultInstance for Version { fn default_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); - VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Version::default())) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } impl ::buffa::Message for Version { @@ -256,10 +256,7 @@ impl CodeGeneratorRequest { unsafe impl ::buffa::DefaultInstance for CodeGeneratorRequest { fn default_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); - VALUE - .get_or_init(|| ::buffa::alloc::boxed::Box::new( - CodeGeneratorRequest::default(), - )) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } impl ::buffa::Message for CodeGeneratorRequest { @@ -515,10 +512,7 @@ impl CodeGeneratorResponse { unsafe impl ::buffa::DefaultInstance for CodeGeneratorResponse { fn default_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); - VALUE - .get_or_init(|| ::buffa::alloc::boxed::Box::new( - CodeGeneratorResponse::default(), - )) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } impl ::buffa::Message for CodeGeneratorResponse { @@ -831,7 +825,7 @@ pub mod code_generator_response { unsafe impl ::buffa::DefaultInstance for File { fn default_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); - VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(File::default())) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } impl ::buffa::Message for File { diff --git a/buffa-descriptor/src/generated/google.protobuf.descriptor.rs b/buffa-descriptor/src/generated/google.protobuf.descriptor.rs index 3de7c27..e86540d 100644 --- a/buffa-descriptor/src/generated/google.protobuf.descriptor.rs +++ b/buffa-descriptor/src/generated/google.protobuf.descriptor.rs @@ -179,10 +179,7 @@ impl FileDescriptorSet { unsafe impl ::buffa::DefaultInstance for FileDescriptorSet { fn default_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); - VALUE - .get_or_init(|| ::buffa::alloc::boxed::Box::new( - FileDescriptorSet::default(), - )) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } impl ::buffa::Message for FileDescriptorSet { @@ -367,10 +364,7 @@ impl FileDescriptorProto { unsafe impl ::buffa::DefaultInstance for FileDescriptorProto { fn default_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); - VALUE - .get_or_init(|| ::buffa::alloc::boxed::Box::new( - FileDescriptorProto::default(), - )) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } impl ::buffa::Message for FileDescriptorProto { @@ -839,7 +833,7 @@ pub struct DescriptorProto { /// Field 6: `extension` pub extension: ::buffa::alloc::vec::Vec, /// Field 3: `nested_type` - pub nested_type: ::buffa::alloc::vec::Vec, + pub nested_type: ::buffa::alloc::vec::Vec, /// Field 4: `enum_type` pub enum_type: ::buffa::alloc::vec::Vec, /// Field 5: `extension_range` @@ -891,7 +885,7 @@ impl DescriptorProto { unsafe impl ::buffa::DefaultInstance for DescriptorProto { fn default_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); - VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(DescriptorProto::default())) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } impl ::buffa::Message for DescriptorProto { @@ -1290,10 +1284,7 @@ pub mod descriptor_proto { unsafe impl ::buffa::DefaultInstance for ExtensionRange { fn default_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); - VALUE - .get_or_init(|| ::buffa::alloc::boxed::Box::new( - ExtensionRange::default(), - )) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } impl ::buffa::Message for ExtensionRange { @@ -1458,10 +1449,7 @@ pub mod descriptor_proto { unsafe impl ::buffa::DefaultInstance for ReservedRange { fn default_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); - VALUE - .get_or_init(|| ::buffa::alloc::boxed::Box::new( - ReservedRange::default(), - )) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } impl ::buffa::Message for ReservedRange { @@ -1608,10 +1596,7 @@ impl ExtensionRangeOptions { unsafe impl ::buffa::DefaultInstance for ExtensionRangeOptions { fn default_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); - VALUE - .get_or_init(|| ::buffa::alloc::boxed::Box::new( - ExtensionRangeOptions::default(), - )) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } impl ::buffa::Message for ExtensionRangeOptions { @@ -1879,7 +1864,7 @@ pub mod extension_range_options { unsafe impl ::buffa::DefaultInstance for Declaration { fn default_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); - VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Declaration::default())) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } impl ::buffa::Message for Declaration { @@ -2158,10 +2143,7 @@ impl FieldDescriptorProto { unsafe impl ::buffa::DefaultInstance for FieldDescriptorProto { fn default_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); - VALUE - .get_or_init(|| ::buffa::alloc::boxed::Box::new( - FieldDescriptorProto::default(), - )) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } impl ::buffa::Message for FieldDescriptorProto { @@ -2697,10 +2679,7 @@ impl OneofDescriptorProto { unsafe impl ::buffa::DefaultInstance for OneofDescriptorProto { fn default_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); - VALUE - .get_or_init(|| ::buffa::alloc::boxed::Box::new( - OneofDescriptorProto::default(), - )) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } impl ::buffa::Message for OneofDescriptorProto { @@ -2865,10 +2844,7 @@ impl EnumDescriptorProto { unsafe impl ::buffa::DefaultInstance for EnumDescriptorProto { fn default_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); - VALUE - .get_or_init(|| ::buffa::alloc::boxed::Box::new( - EnumDescriptorProto::default(), - )) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } impl ::buffa::Message for EnumDescriptorProto { @@ -3130,10 +3106,7 @@ pub mod enum_descriptor_proto { unsafe impl ::buffa::DefaultInstance for EnumReservedRange { fn default_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); - VALUE - .get_or_init(|| ::buffa::alloc::boxed::Box::new( - EnumReservedRange::default(), - )) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } impl ::buffa::Message for EnumReservedRange { @@ -3266,10 +3239,7 @@ impl EnumValueDescriptorProto { unsafe impl ::buffa::DefaultInstance for EnumValueDescriptorProto { fn default_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); - VALUE - .get_or_init(|| ::buffa::alloc::boxed::Box::new( - EnumValueDescriptorProto::default(), - )) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } impl ::buffa::Message for EnumValueDescriptorProto { @@ -3435,10 +3405,7 @@ impl ServiceDescriptorProto { unsafe impl ::buffa::DefaultInstance for ServiceDescriptorProto { fn default_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); - VALUE - .get_or_init(|| ::buffa::alloc::boxed::Box::new( - ServiceDescriptorProto::default(), - )) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } impl ::buffa::Message for ServiceDescriptorProto { @@ -3627,10 +3594,7 @@ impl MethodDescriptorProto { unsafe impl ::buffa::DefaultInstance for MethodDescriptorProto { fn default_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); - VALUE - .get_or_init(|| ::buffa::alloc::boxed::Box::new( - MethodDescriptorProto::default(), - )) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } impl ::buffa::Message for MethodDescriptorProto { @@ -4044,7 +4008,7 @@ impl FileOptions { unsafe impl ::buffa::DefaultInstance for FileOptions { fn default_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); - VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(FileOptions::default())) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } impl ::buffa::Message for FileOptions { @@ -4801,7 +4765,7 @@ impl MessageOptions { unsafe impl ::buffa::DefaultInstance for MessageOptions { fn default_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); - VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(MessageOptions::default())) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } impl ::buffa::Message for MessageOptions { @@ -5159,7 +5123,7 @@ impl FieldOptions { unsafe impl ::buffa::DefaultInstance for FieldOptions { fn default_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); - VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(FieldOptions::default())) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } impl ::buffa::Message for FieldOptions { @@ -5873,10 +5837,7 @@ pub mod field_options { unsafe impl ::buffa::DefaultInstance for EditionDefault { fn default_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); - VALUE - .get_or_init(|| ::buffa::alloc::boxed::Box::new( - EditionDefault::default(), - )) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } impl ::buffa::Message for EditionDefault { @@ -6040,10 +6001,7 @@ pub mod field_options { unsafe impl ::buffa::DefaultInstance for FeatureSupport { fn default_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); - VALUE - .get_or_init(|| ::buffa::alloc::boxed::Box::new( - FeatureSupport::default(), - )) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } impl ::buffa::Message for FeatureSupport { @@ -6254,7 +6212,7 @@ impl OneofOptions { unsafe impl ::buffa::DefaultInstance for OneofOptions { fn default_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); - VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(OneofOptions::default())) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } impl ::buffa::Message for OneofOptions { @@ -6432,7 +6390,7 @@ impl EnumOptions { unsafe impl ::buffa::DefaultInstance for EnumOptions { fn default_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); - VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(EnumOptions::default())) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } impl ::buffa::Message for EnumOptions { @@ -6666,8 +6624,7 @@ impl EnumValueOptions { unsafe impl ::buffa::DefaultInstance for EnumValueOptions { fn default_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); - VALUE - .get_or_init(|| ::buffa::alloc::boxed::Box::new(EnumValueOptions::default())) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } impl ::buffa::Message for EnumValueOptions { @@ -6906,7 +6863,7 @@ impl ServiceOptions { unsafe impl ::buffa::DefaultInstance for ServiceOptions { fn default_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); - VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(ServiceOptions::default())) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } impl ::buffa::Message for ServiceOptions { @@ -7094,7 +7051,7 @@ impl MethodOptions { unsafe impl ::buffa::DefaultInstance for MethodOptions { fn default_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); - VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(MethodOptions::default())) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } impl ::buffa::Message for MethodOptions { @@ -7364,10 +7321,7 @@ impl UninterpretedOption { unsafe impl ::buffa::DefaultInstance for UninterpretedOption { fn default_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); - VALUE - .get_or_init(|| ::buffa::alloc::boxed::Box::new( - UninterpretedOption::default(), - )) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } impl ::buffa::Message for UninterpretedOption { @@ -7631,7 +7585,7 @@ pub mod uninterpreted_option { unsafe impl ::buffa::DefaultInstance for NamePart { fn default_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); - VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(NamePart::default())) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } impl ::buffa::Message for NamePart { @@ -7780,7 +7734,7 @@ impl FeatureSet { unsafe impl ::buffa::DefaultInstance for FeatureSet { fn default_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); - VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(FeatureSet::default())) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } impl ::buffa::Message for FeatureSet { @@ -8406,10 +8360,7 @@ pub mod feature_set { unsafe impl ::buffa::DefaultInstance for VisibilityFeature { fn default_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); - VALUE - .get_or_init(|| ::buffa::alloc::boxed::Box::new( - VisibilityFeature::default(), - )) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } impl ::buffa::Message for VisibilityFeature { @@ -8581,10 +8532,7 @@ impl FeatureSetDefaults { unsafe impl ::buffa::DefaultInstance for FeatureSetDefaults { fn default_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); - VALUE - .get_or_init(|| ::buffa::alloc::boxed::Box::new( - FeatureSetDefaults::default(), - )) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } impl ::buffa::Message for FeatureSetDefaults { @@ -8772,10 +8720,7 @@ pub mod feature_set_defaults { unsafe impl ::buffa::DefaultInstance for FeatureSetEditionDefault { fn default_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); - VALUE - .get_or_init(|| ::buffa::alloc::boxed::Box::new( - FeatureSetEditionDefault::default(), - )) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } impl ::buffa::Message for FeatureSetEditionDefault { @@ -9004,7 +8949,7 @@ impl SourceCodeInfo { unsafe impl ::buffa::DefaultInstance for SourceCodeInfo { fn default_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); - VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(SourceCodeInfo::default())) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } impl ::buffa::Message for SourceCodeInfo { @@ -9216,7 +9161,7 @@ pub mod source_code_info { unsafe impl ::buffa::DefaultInstance for Location { fn default_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); - VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Location::default())) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } impl ::buffa::Message for Location { @@ -9495,10 +9440,7 @@ impl GeneratedCodeInfo { unsafe impl ::buffa::DefaultInstance for GeneratedCodeInfo { fn default_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); - VALUE - .get_or_init(|| ::buffa::alloc::boxed::Box::new( - GeneratedCodeInfo::default(), - )) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } impl ::buffa::Message for GeneratedCodeInfo { @@ -9636,7 +9578,7 @@ pub mod generated_code_info { unsafe impl ::buffa::DefaultInstance for Annotation { fn default_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); - VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Annotation::default())) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } impl ::buffa::Message for Annotation { diff --git a/buffa-types/src/any_ext.rs b/buffa-types/src/any_ext.rs index 511494a..71dc1ae 100644 --- a/buffa-types/src/any_ext.rs +++ b/buffa-types/src/any_ext.rs @@ -11,7 +11,7 @@ impl Any { /// `type.googleapis.com/fully.qualified.TypeName`, but this method does /// not enforce that convention — any string is accepted. pub fn pack(msg: &impl buffa::Message, type_url: impl Into) -> Self { - Any { + Self { type_url: type_url.into(), value: msg.encode_to_vec(), ..Default::default() @@ -202,7 +202,7 @@ impl<'de> serde::Deserialize<'de> for Any { Some(_) => { return Err(serde::de::Error::custom("@type must be a string")); } - None => return Ok(Any::default()), + None => return Ok(Self::default()), }; // The type URL must be non-empty and contain a '/' separating the @@ -239,7 +239,7 @@ impl<'de> serde::Deserialize<'de> for Any { } }; - Ok(Any { + Ok(Self { type_url, value, ..Default::default() diff --git a/buffa-types/src/duration_ext.rs b/buffa-types/src/duration_ext.rs index 61b4d86..9dda2e6 100644 --- a/buffa-types/src/duration_ext.rs +++ b/buffa-types/src/duration_ext.rs @@ -47,7 +47,7 @@ impl TryFrom for std::time::Duration { if d.seconds < 0 || d.nanos < 0 { return Err(DurationError::NegativeDuration); } - Ok(std::time::Duration::new(d.seconds as u64, d.nanos as u32)) + Ok(Self::new(d.seconds as u64, d.nanos as u32)) } } @@ -61,7 +61,7 @@ impl From for Duration { /// saturated to `i64::MAX` seconds rather than wrapping, which would produce /// an incorrect negative value. fn from(d: std::time::Duration) -> Self { - Duration { + Self { // Saturate at i64::MAX rather than wrapping for extremely large durations. seconds: d.as_secs().min(i64::MAX as u64) as i64, nanos: d.subsec_nanos() as i32, @@ -192,7 +192,7 @@ impl<'de> serde::Deserialize<'de> for Duration { let s: String = serde::Deserialize::deserialize(d)?; let (seconds, nanos) = parse_duration_string(&s) .ok_or_else(|| serde::de::Error::custom(format!("invalid Duration string: {s}")))?; - Ok(Duration { + Ok(Self { seconds, nanos, ..Default::default() @@ -203,7 +203,7 @@ impl<'de> serde::Deserialize<'de> for Duration { impl Duration { /// Create a [`Duration`] from a whole number of seconds. pub fn from_secs(seconds: i64) -> Self { - Duration { + Self { seconds, nanos: 0, ..Default::default() @@ -229,7 +229,7 @@ impl Duration { !((seconds > 0 && nanos < 0) || (seconds < 0 && nanos > 0)), "nanos sign must be consistent with seconds sign" ); - Duration { + Self { seconds, nanos, ..Default::default() @@ -246,7 +246,7 @@ impl Duration { if (seconds > 0 && nanos < 0) || (seconds < 0 && nanos > 0) { return None; } - Some(Duration { + Some(Self { seconds, nanos, ..Default::default() @@ -258,7 +258,7 @@ impl Duration { /// The sign of `millis` determines the sign of both `seconds` and the /// sub-second `nanos` field, per the protobuf sign-consistency rule. pub fn from_millis(millis: i64) -> Self { - Duration { + Self { seconds: millis / 1_000, // Remainder is in [-999, 999]; after ×1_000_000 → [-999_000_000, 999_000_000], // which fits in i32 (max ≈ ±2.1 billion). Cast is lossless. @@ -269,7 +269,7 @@ impl Duration { /// Create a [`Duration`] from a number of microseconds. pub fn from_micros(micros: i64) -> Self { - Duration { + Self { seconds: micros / 1_000_000, // Remainder is in [-999_999, 999_999]; after ×1_000 → [-999_999_000, 999_999_000], // which fits in i32. Cast is lossless. @@ -280,7 +280,7 @@ impl Duration { /// Create a [`Duration`] from a number of nanoseconds. pub fn from_nanos(nanos: i64) -> Self { - Duration { + Self { seconds: nanos / 1_000_000_000, // Remainder is in [-999_999_999, 999_999_999], which fits in i32. Cast is lossless. nanos: (nanos % 1_000_000_000) as i32, diff --git a/buffa-types/src/field_mask_ext.rs b/buffa-types/src/field_mask_ext.rs index 4c1da86..7a03ff5 100644 --- a/buffa-types/src/field_mask_ext.rs +++ b/buffa-types/src/field_mask_ext.rs @@ -16,7 +16,7 @@ impl FieldMask { /// assert!(mask.contains("user.name")); /// ``` pub fn from_paths(paths: impl IntoIterator>) -> Self { - FieldMask { + Self { paths: paths.into_iter().map(Into::into).collect(), ..Default::default() } @@ -176,7 +176,7 @@ impl<'de> serde::Deserialize<'de> for FieldMask { }) .collect::>()? }; - Ok(FieldMask { + Ok(Self { paths, ..Default::default() }) diff --git a/buffa-types/src/generated/google.protobuf.any.rs b/buffa-types/src/generated/google.protobuf.any.rs index 330a0ab..5737b40 100644 --- a/buffa-types/src/generated/google.protobuf.any.rs +++ b/buffa-types/src/generated/google.protobuf.any.rs @@ -159,7 +159,7 @@ impl Any { unsafe impl ::buffa::DefaultInstance for Any { fn default_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); - VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Any::default())) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } impl ::buffa::Message for Any { @@ -495,7 +495,7 @@ impl<'a> ::buffa::MessageView<'a> for AnyView<'a> { unsafe impl ::buffa::DefaultViewInstance for AnyView<'static> { fn default_view_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox> = ::buffa::__private::OnceBox::new(); - VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(AnyView::default())) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } unsafe impl<'a> ::buffa::HasDefaultViewInstance for AnyView<'a> { diff --git a/buffa-types/src/generated/google.protobuf.duration.rs b/buffa-types/src/generated/google.protobuf.duration.rs index 884bba1..88e8c8b 100644 --- a/buffa-types/src/generated/google.protobuf.duration.rs +++ b/buffa-types/src/generated/google.protobuf.duration.rs @@ -106,7 +106,7 @@ impl Duration { unsafe impl ::buffa::DefaultInstance for Duration { fn default_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); - VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Duration::default())) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } impl ::buffa::Message for Duration { @@ -383,7 +383,7 @@ impl<'a> ::buffa::MessageView<'a> for DurationView<'a> { unsafe impl ::buffa::DefaultViewInstance for DurationView<'static> { fn default_view_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox> = ::buffa::__private::OnceBox::new(); - VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(DurationView::default())) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } unsafe impl<'a> ::buffa::HasDefaultViewInstance for DurationView<'a> { diff --git a/buffa-types/src/generated/google.protobuf.empty.rs b/buffa-types/src/generated/google.protobuf.empty.rs index 66cf514..03092a9 100644 --- a/buffa-types/src/generated/google.protobuf.empty.rs +++ b/buffa-types/src/generated/google.protobuf.empty.rs @@ -33,7 +33,7 @@ impl Empty { unsafe impl ::buffa::DefaultInstance for Empty { fn default_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); - VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Empty::default())) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } impl ::buffa::Message for Empty { @@ -180,7 +180,7 @@ impl<'a> ::buffa::MessageView<'a> for EmptyView<'a> { unsafe impl ::buffa::DefaultViewInstance for EmptyView<'static> { fn default_view_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox> = ::buffa::__private::OnceBox::new(); - VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(EmptyView::default())) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } unsafe impl<'a> ::buffa::HasDefaultViewInstance for EmptyView<'a> { diff --git a/buffa-types/src/generated/google.protobuf.field_mask.rs b/buffa-types/src/generated/google.protobuf.field_mask.rs index 82c21ff..24a25f9 100644 --- a/buffa-types/src/generated/google.protobuf.field_mask.rs +++ b/buffa-types/src/generated/google.protobuf.field_mask.rs @@ -251,7 +251,7 @@ impl FieldMask { unsafe impl ::buffa::DefaultInstance for FieldMask { fn default_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); - VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(FieldMask::default())) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } impl ::buffa::Message for FieldMask { @@ -649,7 +649,7 @@ impl<'a> ::buffa::MessageView<'a> for FieldMaskView<'a> { unsafe impl ::buffa::DefaultViewInstance for FieldMaskView<'static> { fn default_view_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox> = ::buffa::__private::OnceBox::new(); - VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(FieldMaskView::default())) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } unsafe impl<'a> ::buffa::HasDefaultViewInstance for FieldMaskView<'a> { diff --git a/buffa-types/src/generated/google.protobuf.struct.rs b/buffa-types/src/generated/google.protobuf.struct.rs index aecf1d0..7dc6f12 100644 --- a/buffa-types/src/generated/google.protobuf.struct.rs +++ b/buffa-types/src/generated/google.protobuf.struct.rs @@ -74,7 +74,7 @@ impl Struct { unsafe impl ::buffa::DefaultInstance for Struct { fn default_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); - VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Struct::default())) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } impl ::buffa::Message for Struct { @@ -389,7 +389,7 @@ impl<'a> ::buffa::MessageView<'a> for StructView<'a> { unsafe impl ::buffa::DefaultViewInstance for StructView<'static> { fn default_view_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox> = ::buffa::__private::OnceBox::new(); - VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(StructView::default())) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } unsafe impl<'a> ::buffa::HasDefaultViewInstance for StructView<'a> { @@ -425,7 +425,7 @@ impl Value { unsafe impl ::buffa::DefaultInstance for Value { fn default_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); - VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Value::default())) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } impl ::buffa::Message for Value { @@ -883,7 +883,7 @@ impl<'a> ::buffa::MessageView<'a> for ValueView<'a> { unsafe impl ::buffa::DefaultViewInstance for ValueView<'static> { fn default_view_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox> = ::buffa::__private::OnceBox::new(); - VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(ValueView::default())) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } unsafe impl<'a> ::buffa::HasDefaultViewInstance for ValueView<'a> { @@ -906,22 +906,22 @@ pub mod value { impl ::buffa::Oneof for Kind {} impl From for Kind { fn from(v: super::Struct) -> Self { - Kind::StructValue(::buffa::alloc::boxed::Box::new(v)) + Self::StructValue(::buffa::alloc::boxed::Box::new(v)) } } impl From for ::core::option::Option { fn from(v: super::Struct) -> Self { - ::core::option::Option::Some(Kind::from(v)) + Self::Some(Kind::from(v)) } } impl From for Kind { fn from(v: super::ListValue) -> Self { - Kind::ListValue(::buffa::alloc::boxed::Box::new(v)) + Self::ListValue(::buffa::alloc::boxed::Box::new(v)) } } impl From for ::core::option::Option { fn from(v: super::ListValue) -> Self { - ::core::option::Option::Some(Kind::from(v)) + Self::Some(Kind::from(v)) } } #[derive(Clone, Debug)] @@ -964,7 +964,7 @@ impl ListValue { unsafe impl ::buffa::DefaultInstance for ListValue { fn default_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); - VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(ListValue::default())) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } impl ::buffa::Message for ListValue { @@ -1152,7 +1152,7 @@ impl<'a> ::buffa::MessageView<'a> for ListValueView<'a> { unsafe impl ::buffa::DefaultViewInstance for ListValueView<'static> { fn default_view_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox> = ::buffa::__private::OnceBox::new(); - VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(ListValueView::default())) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } unsafe impl<'a> ::buffa::HasDefaultViewInstance for ListValueView<'a> { diff --git a/buffa-types/src/generated/google.protobuf.timestamp.rs b/buffa-types/src/generated/google.protobuf.timestamp.rs index aa140d8..0112a72 100644 --- a/buffa-types/src/generated/google.protobuf.timestamp.rs +++ b/buffa-types/src/generated/google.protobuf.timestamp.rs @@ -141,7 +141,7 @@ impl Timestamp { unsafe impl ::buffa::DefaultInstance for Timestamp { fn default_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); - VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Timestamp::default())) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } impl ::buffa::Message for Timestamp { @@ -453,7 +453,7 @@ impl<'a> ::buffa::MessageView<'a> for TimestampView<'a> { unsafe impl ::buffa::DefaultViewInstance for TimestampView<'static> { fn default_view_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox> = ::buffa::__private::OnceBox::new(); - VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(TimestampView::default())) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } unsafe impl<'a> ::buffa::HasDefaultViewInstance for TimestampView<'a> { diff --git a/buffa-types/src/generated/google.protobuf.wrappers.rs b/buffa-types/src/generated/google.protobuf.wrappers.rs index 7d581fc..d99c5f9 100644 --- a/buffa-types/src/generated/google.protobuf.wrappers.rs +++ b/buffa-types/src/generated/google.protobuf.wrappers.rs @@ -31,7 +31,7 @@ impl DoubleValue { unsafe impl ::buffa::DefaultInstance for DoubleValue { fn default_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); - VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(DoubleValue::default())) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } impl ::buffa::Message for DoubleValue { @@ -206,7 +206,7 @@ impl<'a> ::buffa::MessageView<'a> for DoubleValueView<'a> { unsafe impl ::buffa::DefaultViewInstance for DoubleValueView<'static> { fn default_view_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox> = ::buffa::__private::OnceBox::new(); - VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(DoubleValueView::default())) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } unsafe impl<'a> ::buffa::HasDefaultViewInstance for DoubleValueView<'a> { @@ -242,7 +242,7 @@ impl FloatValue { unsafe impl ::buffa::DefaultInstance for FloatValue { fn default_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); - VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(FloatValue::default())) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } impl ::buffa::Message for FloatValue { @@ -417,7 +417,7 @@ impl<'a> ::buffa::MessageView<'a> for FloatValueView<'a> { unsafe impl ::buffa::DefaultViewInstance for FloatValueView<'static> { fn default_view_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox> = ::buffa::__private::OnceBox::new(); - VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(FloatValueView::default())) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } unsafe impl<'a> ::buffa::HasDefaultViewInstance for FloatValueView<'a> { @@ -453,7 +453,7 @@ impl Int64Value { unsafe impl ::buffa::DefaultInstance for Int64Value { fn default_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); - VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Int64Value::default())) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } impl ::buffa::Message for Int64Value { @@ -628,7 +628,7 @@ impl<'a> ::buffa::MessageView<'a> for Int64ValueView<'a> { unsafe impl ::buffa::DefaultViewInstance for Int64ValueView<'static> { fn default_view_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox> = ::buffa::__private::OnceBox::new(); - VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Int64ValueView::default())) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } unsafe impl<'a> ::buffa::HasDefaultViewInstance for Int64ValueView<'a> { @@ -664,7 +664,7 @@ impl UInt64Value { unsafe impl ::buffa::DefaultInstance for UInt64Value { fn default_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); - VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(UInt64Value::default())) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } impl ::buffa::Message for UInt64Value { @@ -839,7 +839,7 @@ impl<'a> ::buffa::MessageView<'a> for UInt64ValueView<'a> { unsafe impl ::buffa::DefaultViewInstance for UInt64ValueView<'static> { fn default_view_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox> = ::buffa::__private::OnceBox::new(); - VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(UInt64ValueView::default())) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } unsafe impl<'a> ::buffa::HasDefaultViewInstance for UInt64ValueView<'a> { @@ -875,7 +875,7 @@ impl Int32Value { unsafe impl ::buffa::DefaultInstance for Int32Value { fn default_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); - VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Int32Value::default())) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } impl ::buffa::Message for Int32Value { @@ -1050,7 +1050,7 @@ impl<'a> ::buffa::MessageView<'a> for Int32ValueView<'a> { unsafe impl ::buffa::DefaultViewInstance for Int32ValueView<'static> { fn default_view_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox> = ::buffa::__private::OnceBox::new(); - VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Int32ValueView::default())) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } unsafe impl<'a> ::buffa::HasDefaultViewInstance for Int32ValueView<'a> { @@ -1086,7 +1086,7 @@ impl UInt32Value { unsafe impl ::buffa::DefaultInstance for UInt32Value { fn default_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); - VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(UInt32Value::default())) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } impl ::buffa::Message for UInt32Value { @@ -1261,7 +1261,7 @@ impl<'a> ::buffa::MessageView<'a> for UInt32ValueView<'a> { unsafe impl ::buffa::DefaultViewInstance for UInt32ValueView<'static> { fn default_view_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox> = ::buffa::__private::OnceBox::new(); - VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(UInt32ValueView::default())) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } unsafe impl<'a> ::buffa::HasDefaultViewInstance for UInt32ValueView<'a> { @@ -1297,7 +1297,7 @@ impl BoolValue { unsafe impl ::buffa::DefaultInstance for BoolValue { fn default_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); - VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(BoolValue::default())) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } impl ::buffa::Message for BoolValue { @@ -1472,7 +1472,7 @@ impl<'a> ::buffa::MessageView<'a> for BoolValueView<'a> { unsafe impl ::buffa::DefaultViewInstance for BoolValueView<'static> { fn default_view_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox> = ::buffa::__private::OnceBox::new(); - VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(BoolValueView::default())) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } unsafe impl<'a> ::buffa::HasDefaultViewInstance for BoolValueView<'a> { @@ -1508,7 +1508,7 @@ impl StringValue { unsafe impl ::buffa::DefaultInstance for StringValue { fn default_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); - VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(StringValue::default())) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } impl ::buffa::Message for StringValue { @@ -1686,7 +1686,7 @@ impl<'a> ::buffa::MessageView<'a> for StringValueView<'a> { unsafe impl ::buffa::DefaultViewInstance for StringValueView<'static> { fn default_view_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox> = ::buffa::__private::OnceBox::new(); - VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(StringValueView::default())) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } unsafe impl<'a> ::buffa::HasDefaultViewInstance for StringValueView<'a> { @@ -1722,7 +1722,7 @@ impl BytesValue { unsafe impl ::buffa::DefaultInstance for BytesValue { fn default_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); - VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(BytesValue::default())) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } impl ::buffa::Message for BytesValue { @@ -1900,7 +1900,7 @@ impl<'a> ::buffa::MessageView<'a> for BytesValueView<'a> { unsafe impl ::buffa::DefaultViewInstance for BytesValueView<'static> { fn default_view_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox> = ::buffa::__private::OnceBox::new(); - VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(BytesValueView::default())) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } unsafe impl<'a> ::buffa::HasDefaultViewInstance for BytesValueView<'a> { diff --git a/buffa-types/src/timestamp_ext.rs b/buffa-types/src/timestamp_ext.rs index be38c7b..38e42ae 100644 --- a/buffa-types/src/timestamp_ext.rs +++ b/buffa-types/src/timestamp_ext.rs @@ -30,7 +30,7 @@ impl Timestamp { (0..=999_999_999).contains(&nanos), "nanos ({nanos}) must be in [0, 999_999_999]" ); - Timestamp { + Self { seconds, nanos, ..Default::default() @@ -41,7 +41,7 @@ impl Timestamp { /// /// This is a convenience shorthand for `Timestamp::from_unix(seconds, 0)`. pub fn from_unix_secs(seconds: i64) -> Self { - Timestamp { + Self { seconds, nanos: 0, ..Default::default() @@ -52,7 +52,7 @@ impl Timestamp { /// `nanos` is outside `[0, 999_999_999]`. pub fn from_unix_checked(seconds: i64, nanos: i32) -> Option { if (0..=999_999_999).contains(&nanos) { - Some(Timestamp { + Some(Self { seconds, nanos, ..Default::default() @@ -130,7 +130,7 @@ impl From for Timestamp { /// which would produce a semantically incorrect negative timestamp. fn from(t: std::time::SystemTime) -> Self { match t.duration_since(std::time::UNIX_EPOCH) { - Ok(d) => Timestamp { + Ok(d) => Self { // Saturate at i64::MAX to avoid wrapping for times far in the future. seconds: d.as_secs().min(i64::MAX as u64) as i64, nanos: d.subsec_nanos() as i32, @@ -155,7 +155,7 @@ impl From for Timestamp { let dur = e.duration(); if dur.subsec_nanos() == 0 { let secs = dur.as_secs().min(i64::MAX as u64) as i64; - Timestamp { + Self { seconds: -secs, nanos: 0, ..Default::default() @@ -164,7 +164,7 @@ impl From for Timestamp { // saturating_add avoids overflow when dur.as_secs() == u64::MAX, // then clamp to i64::MAX before converting. let neg_secs = dur.as_secs().saturating_add(1).min(i64::MAX as u64) as i64; - Timestamp { + Self { seconds: -neg_secs, nanos: (1_000_000_000u32 - dur.subsec_nanos()) as i32, ..Default::default() @@ -387,7 +387,7 @@ impl<'de> serde::Deserialize<'de> for Timestamp { let s: String = serde::Deserialize::deserialize(d)?; let (secs, nanos) = parse_rfc3339(&s) .ok_or_else(|| serde::de::Error::custom(format!("invalid RFC 3339 timestamp: {s}")))?; - Ok(Timestamp { + Ok(Self { seconds: secs, nanos, ..Default::default() diff --git a/buffa-types/src/value_ext.rs b/buffa-types/src/value_ext.rs index 7c756e1..dc6f2cf 100644 --- a/buffa-types/src/value_ext.rs +++ b/buffa-types/src/value_ext.rs @@ -10,7 +10,7 @@ use crate::google::protobuf::{value::Kind, ListValue, NullValue, Struct, Value}; impl Value { /// Construct a [`Value`] that represents a protobuf `null`. pub fn null() -> Self { - Value { + Self { kind: Some(Kind::NullValue(buffa::EnumValue::from( NullValue::NULL_VALUE, ))), @@ -82,7 +82,7 @@ impl Value { impl From for Value { fn from(n: f64) -> Self { - Value { + Self { kind: Some(Kind::NumberValue(n)), ..Default::default() } @@ -91,7 +91,7 @@ impl From for Value { impl From for Value { fn from(s: String) -> Self { - Value { + Self { kind: Some(Kind::StringValue(s)), ..Default::default() } @@ -100,7 +100,7 @@ impl From for Value { impl From<&str> for Value { fn from(s: &str) -> Self { - Value { + Self { kind: Some(Kind::StringValue(s.to_string())), ..Default::default() } @@ -113,13 +113,13 @@ impl From for Value { /// The conversion is lossless for values representable as both `f32` and /// `f64`; the extra precision bits are filled with zeros. fn from(n: f32) -> Self { - Value::from(n as f64) + Self::from(n as f64) } } impl From for Value { fn from(b: bool) -> Self { - Value { + Self { kind: Some(Kind::BoolValue(b)), ..Default::default() } @@ -131,7 +131,7 @@ impl From for Value { /// /// All `i32` values are representable exactly as `f64`. fn from(n: i32) -> Self { - Value::from(n as f64) + Self::from(n as f64) } } @@ -140,7 +140,7 @@ impl From for Value { /// /// All `u32` values are representable exactly as `f64`. fn from(n: u32) -> Self { - Value::from(n as f64) + Self::from(n as f64) } } @@ -152,7 +152,7 @@ impl From for Value { /// `f64` has 53 bits of mantissa. `i64` values outside `[-2^53, 2^53]` /// will be rounded to the nearest representable `f64`. fn from(n: i64) -> Self { - Value::from(n as f64) + Self::from(n as f64) } } @@ -164,13 +164,13 @@ impl From for Value { /// `f64` has 53 bits of mantissa. `u64` values greater than `2^53` /// will be rounded to the nearest representable `f64`. fn from(n: u64) -> Self { - Value::from(n as f64) + Self::from(n as f64) } } impl From for Value { fn from(s: Struct) -> Self { - Value { + Self { kind: Some(Kind::StructValue(Box::new(s))), ..Default::default() } @@ -179,7 +179,7 @@ impl From for Value { impl From for Value { fn from(l: ListValue) -> Self { - Value { + Self { kind: Some(Kind::ListValue(Box::new(l))), ..Default::default() } @@ -189,7 +189,7 @@ impl From for Value { impl ListValue { /// Construct a [`ListValue`] from an iterator of items convertible to [`Value`]. pub fn from_values(values: impl IntoIterator>) -> Self { - ListValue { + Self { values: values.into_iter().map(Into::into).collect(), ..Default::default() } @@ -235,7 +235,7 @@ impl IntoIterator for ListValue { impl FromIterator for ListValue { /// Collect [`Value`] items into a [`ListValue`]. fn from_iter>(iter: T) -> Self { - ListValue { + Self { values: iter.into_iter().collect(), ..Default::default() } diff --git a/buffa-types/src/wrapper_ext.rs b/buffa-types/src/wrapper_ext.rs index a58d151..c1fb3ed 100644 --- a/buffa-types/src/wrapper_ext.rs +++ b/buffa-types/src/wrapper_ext.rs @@ -45,7 +45,7 @@ impl_wrapper!(BytesValue, Vec); impl From<&str> for StringValue { /// Converts a string slice into a [`StringValue`], allocating a new `String`. fn from(s: &str) -> Self { - StringValue { + Self { value: s.to_string(), ..Default::default() } @@ -55,7 +55,7 @@ impl From<&str> for StringValue { impl From<&[u8]> for BytesValue { /// Converts a byte slice into a [`BytesValue`], copying the bytes. fn from(b: &[u8]) -> Self { - BytesValue { + Self { value: b.to_vec(), ..Default::default() } diff --git a/buffa/src/any_registry.rs b/buffa/src/any_registry.rs index c102f4a..bbf13f0 100644 --- a/buffa/src/any_registry.rs +++ b/buffa/src/any_registry.rs @@ -64,7 +64,7 @@ pub struct AnyRegistry { impl AnyRegistry { /// Creates an empty registry. pub fn new() -> Self { - AnyRegistry { + Self { entries: HashMap::new(), } } diff --git a/buffa/src/encoding.rs b/buffa/src/encoding.rs index 937a40f..90c50e5 100644 --- a/buffa/src/encoding.rs +++ b/buffa/src/encoding.rs @@ -43,12 +43,12 @@ impl WireType { /// recognised wire type (i.e. not in 0–5). pub fn from_u32(value: u32) -> Result { match value { - 0 => Ok(WireType::Varint), - 1 => Ok(WireType::Fixed64), - 2 => Ok(WireType::LengthDelimited), - 3 => Ok(WireType::StartGroup), - 4 => Ok(WireType::EndGroup), - 5 => Ok(WireType::Fixed32), + 0 => Ok(Self::Varint), + 1 => Ok(Self::Fixed64), + 2 => Ok(Self::LengthDelimited), + 3 => Ok(Self::StartGroup), + 4 => Ok(Self::EndGroup), + 5 => Ok(Self::Fixed32), _ => Err(DecodeError::InvalidWireType(value)), } } @@ -150,7 +150,7 @@ impl Tag { } // `field_number` is a u32 right-shifted by 3, so it is bounded by // u32::MAX >> 3 = MAX_FIELD_NUMBER. No upper range check required. - Ok(Tag { + Ok(Self { field_number, wire_type, }) diff --git a/buffa/src/enumeration.rs b/buffa/src/enumeration.rs index 177a5da..f034ea2 100644 --- a/buffa/src/enumeration.rs +++ b/buffa/src/enumeration.rs @@ -48,8 +48,8 @@ impl EnumValue { #[inline] pub fn to_i32(&self) -> i32 { match self { - EnumValue::Known(e) => e.to_i32(), - EnumValue::Unknown(v) => *v, + Self::Known(e) => e.to_i32(), + Self::Unknown(v) => *v, } } @@ -59,21 +59,21 @@ impl EnumValue { /// [`MessageField::is_set`](crate::MessageField::is_set) pattern. #[inline] pub fn is_known(&self) -> bool { - matches!(self, EnumValue::Known(_)) + matches!(self, Self::Known(_)) } /// Returns `true` if the wire value was not recognized as a known variant. #[inline] pub fn is_unknown(&self) -> bool { - matches!(self, EnumValue::Unknown(_)) + matches!(self, Self::Unknown(_)) } /// Try to convert to a known enum variant. #[inline] pub fn as_known(&self) -> Option { match self { - EnumValue::Known(e) => Some(*e), - EnumValue::Unknown(_) => None, + Self::Known(e) => Some(*e), + Self::Unknown(_) => None, } } } @@ -81,15 +81,15 @@ impl EnumValue { impl From for EnumValue { fn from(value: i32) -> Self { match E::from_i32(value) { - Some(e) => EnumValue::Known(e), - None => EnumValue::Unknown(value), + Some(e) => Self::Known(e), + None => Self::Unknown(value), } } } impl From for EnumValue { fn from(value: E) -> Self { - EnumValue::Known(value) + Self::Known(value) } } @@ -106,8 +106,8 @@ impl From for EnumValue { impl PartialEq for EnumValue { fn eq(&self, other: &E) -> bool { match self { - EnumValue::Known(e) => e == other, - EnumValue::Unknown(_) => false, + Self::Known(e) => e == other, + Self::Unknown(_) => false, } } } @@ -115,8 +115,8 @@ impl PartialEq for EnumValue { impl fmt::Debug for EnumValue { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - EnumValue::Known(e) => write!(f, "{:?}", e), - EnumValue::Unknown(v) => write!(f, "Unknown({v})"), + Self::Known(e) => write!(f, "{:?}", e), + Self::Unknown(v) => write!(f, "Unknown({v})"), } } } @@ -124,8 +124,8 @@ impl fmt::Debug for EnumValue { impl fmt::Display for EnumValue { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - EnumValue::Known(e) => f.write_str(e.proto_name()), - EnumValue::Unknown(v) => write!(f, "{v}"), + Self::Known(e) => f.write_str(e.proto_name()), + Self::Unknown(v) => write!(f, "{v}"), } } } @@ -134,8 +134,8 @@ impl fmt::Display for EnumValue { impl serde::Serialize for EnumValue { fn serialize(&self, s: S) -> Result { match self { - EnumValue::Known(e) => s.serialize_str(e.proto_name()), - EnumValue::Unknown(v) => s.serialize_i32(*v), + Self::Known(e) => s.serialize_str(e.proto_name()), + Self::Unknown(v) => s.serialize_i32(*v), } } } @@ -205,7 +205,7 @@ impl Default for EnumValue { /// the correct protobuf default but may be surprising — the field's default /// is technically an unknown variant. fn default() -> Self { - EnumValue::from(0) + Self::from(0) } } diff --git a/buffa/src/json_helpers.rs b/buffa/src/json_helpers.rs index 7c6b852..2a47380 100644 --- a/buffa/src/json_helpers.rs +++ b/buffa/src/json_helpers.rs @@ -1044,7 +1044,7 @@ impl ProtoElemJson for ::bytes::Bytes { // or integer on deserialize, preserve unknown values as the int). impl ProtoElemJson for crate::EnumValue where - crate::EnumValue: serde::Serialize + serde::de::DeserializeOwned, + Self: serde::Serialize + serde::de::DeserializeOwned, { fn serialize_proto_json(v: &Self, s: S) -> Result { serde::Serialize::serialize(v, s) diff --git a/buffa/src/lib.rs b/buffa/src/lib.rs index ce9fce6..7012a54 100644 --- a/buffa/src/lib.rs +++ b/buffa/src/lib.rs @@ -217,7 +217,7 @@ pub mod __doctest_fixtures { unsafe impl DefaultInstance for Person { fn default_instance() -> &'static Self { static INST: __private::OnceBox = __private::OnceBox::new(); - INST.get_or_init(|| alloc::boxed::Box::new(Person::default())) + INST.get_or_init(|| alloc::boxed::Box::new(Self::default())) } } diff --git a/buffa/src/message_field.rs b/buffa/src/message_field.rs index 14f32ca..387ecc3 100644 --- a/buffa/src/message_field.rs +++ b/buffa/src/message_field.rs @@ -327,8 +327,8 @@ impl serde::Serialize for MessageField { impl<'de, T: Default + serde::Deserialize<'de>> serde::Deserialize<'de> for MessageField { fn deserialize>(d: D) -> Result { Option::::deserialize(d).map(|opt| match opt { - Some(v) => MessageField::some(v), - None => MessageField::none(), + Some(v) => Self::some(v), + None => Self::none(), }) } } diff --git a/buffa/src/unknown_fields.rs b/buffa/src/unknown_fields.rs index 6d1c1bc..c2f857d 100644 --- a/buffa/src/unknown_fields.rs +++ b/buffa/src/unknown_fields.rs @@ -159,23 +159,23 @@ pub enum UnknownFieldData { impl UnknownFieldData { fn wire_type_value(&self) -> u64 { match self { - UnknownFieldData::Varint(_) => 0, - UnknownFieldData::Fixed64(_) => 1, - UnknownFieldData::LengthDelimited(_) => 2, - UnknownFieldData::Group(_) => 3, - UnknownFieldData::Fixed32(_) => 5, + Self::Varint(_) => 0, + Self::Fixed64(_) => 1, + Self::LengthDelimited(_) => 2, + Self::Group(_) => 3, + Self::Fixed32(_) => 5, } } fn encoded_len(&self, field_number: u32) -> usize { match self { - UnknownFieldData::Varint(v) => crate::encoding::varint_len(*v), - UnknownFieldData::Fixed64(_) => 8, - UnknownFieldData::Fixed32(_) => 4, - UnknownFieldData::LengthDelimited(data) => { + Self::Varint(v) => crate::encoding::varint_len(*v), + Self::Fixed64(_) => 8, + Self::Fixed32(_) => 4, + Self::LengthDelimited(data) => { crate::encoding::varint_len(data.len() as u64) + data.len() } - UnknownFieldData::Group(fields) => { + Self::Group(fields) => { // Group content + end-group tag (wire type 4, same field number). let end_tag_len = crate::encoding::varint_len((field_number as u64) << 3 | 4); fields.encoded_len() + end_tag_len diff --git a/buffa/src/view.rs b/buffa/src/view.rs index 303cdd9..de795b9 100644 --- a/buffa/src/view.rs +++ b/buffa/src/view.rs @@ -634,7 +634,7 @@ where let slice: &'static [u8] = core::mem::transmute::<&[u8], &'static [u8]>(&bytes); V::decode_view(slice)? }; - Ok(OwnedView { + Ok(Self { view: core::mem::ManuallyDrop::new(view), bytes, }) @@ -656,7 +656,7 @@ where let slice: &'static [u8] = core::mem::transmute::<&[u8], &'static [u8]>(&bytes); opts.decode_view::(slice)? }; - Ok(OwnedView { + Ok(Self { view: core::mem::ManuallyDrop::new(view), bytes, }) @@ -706,7 +706,7 @@ where /// from `bytes` (or a sub-slice that `bytes` fully contains). Violating /// this invariant causes undefined behavior (dangling references). pub unsafe fn from_parts(bytes: Bytes, view: V) -> Self { - OwnedView { + Self { view: core::mem::ManuallyDrop::new(view), bytes, } @@ -756,7 +756,7 @@ where // `'static` references remain valid because they point into data that // is now kept alive by the cloned `Bytes` handle. This would be // unsound if `Bytes::clone()` performed a deep copy to a new address. - OwnedView { + Self { view: self.view.clone(), bytes: self.bytes.clone(), } diff --git a/conformance/Cargo.lock b/conformance/Cargo.lock index 2740d65..6d56441 100644 --- a/conformance/Cargo.lock +++ b/conformance/Cargo.lock @@ -47,6 +47,7 @@ name = "buffa-codegen" version = "0.2.0" dependencies = [ "buffa", + "buffa-descriptor", "prettyplease", "proc-macro2", "quote", @@ -54,6 +55,13 @@ dependencies = [ "thiserror", ] +[[package]] +name = "buffa-descriptor" +version = "0.2.0" +dependencies = [ + "buffa", +] + [[package]] name = "buffa-types" version = "0.2.0" diff --git a/examples/logging/src/gen/context.v1.context.rs b/examples/logging/src/gen/context.v1.context.rs index 15e3db0..c49f247 100644 --- a/examples/logging/src/gen/context.v1.context.rs +++ b/examples/logging/src/gen/context.v1.context.rs @@ -53,7 +53,7 @@ impl RequestContext { unsafe impl ::buffa::DefaultInstance for RequestContext { fn default_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); - VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(RequestContext::default())) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } impl ::buffa::Message for RequestContext { diff --git a/examples/logging/src/gen/log.v1.log.rs b/examples/logging/src/gen/log.v1.log.rs index 70caaab..d544d95 100644 --- a/examples/logging/src/gen/log.v1.log.rs +++ b/examples/logging/src/gen/log.v1.log.rs @@ -113,7 +113,7 @@ impl LogEntry { unsafe impl ::buffa::DefaultInstance for LogEntry { fn default_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); - VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(LogEntry::default())) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } impl ::buffa::Message for LogEntry { @@ -419,7 +419,7 @@ impl LogBatch { unsafe impl ::buffa::DefaultInstance for LogBatch { fn default_instance() -> &'static Self { static VALUE: ::buffa::__private::OnceBox = ::buffa::__private::OnceBox::new(); - VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(LogBatch::default())) + VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default())) } } impl ::buffa::Message for LogBatch { diff --git a/protoc-gen-buffa-packaging/src/main.rs b/protoc-gen-buffa-packaging/src/main.rs index 58326ca..dc7fc61 100644 --- a/protoc-gen-buffa-packaging/src/main.rs +++ b/protoc-gen-buffa-packaging/src/main.rs @@ -71,8 +71,8 @@ enum Filter { impl Filter { fn include(&self, fd: &FileDescriptorProto) -> bool { match self { - Filter::All => true, - Filter::Services => !fd.service.is_empty(), + Self::All => true, + Self::Services => !fd.service.is_empty(), } } }