Skip to main content

buffa_types/generated/
google.protobuf.type.__view.rs

1// @generated by buffa-codegen. DO NOT EDIT.
2// source: google/protobuf/type.proto
3
4/// A protocol buffer message type.
5///
6/// New usages of this message as an alternative to DescriptorProto are strongly
7/// discouraged. This message does not reliability preserve all information
8/// necessary to model the schema and preserve semantics. Instead make use of
9/// FileDescriptorSet which preserves the necessary information.
10#[derive(Clone, Debug, Default)]
11pub struct TypeView<'a> {
12    /// The fully qualified message name.
13    ///
14    /// Field 1: `name`
15    pub name: &'a str,
16    /// The list of fields.
17    ///
18    /// Field 2: `fields`
19    pub fields: ::buffa::RepeatedView<'a, super::super::__buffa::view::FieldView<'a>>,
20    /// The list of types appearing in `oneof` definitions in this type.
21    ///
22    /// Field 3: `oneofs`
23    pub oneofs: ::buffa::RepeatedView<'a, &'a str>,
24    /// The protocol buffer options.
25    ///
26    /// Field 4: `options`
27    pub options: ::buffa::RepeatedView<'a, super::super::__buffa::view::OptionView<'a>>,
28    /// The source context.
29    ///
30    /// Field 5: `source_context`
31    pub source_context: ::buffa::MessageFieldView<
32        super::super::__buffa::view::SourceContextView<'a>,
33    >,
34    /// The source syntax.
35    ///
36    /// Field 6: `syntax`
37    pub syntax: ::buffa::EnumValue<super::super::Syntax>,
38    /// The source edition string, only valid when syntax is SYNTAX_EDITIONS.
39    ///
40    /// Field 7: `edition`
41    pub edition: &'a str,
42    pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
43}
44impl<'a> ::buffa::MessageView<'a> for TypeView<'a> {
45    type Owned = super::super::Type;
46    fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
47        let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT);
48        let __elem = ::core::cell::Cell::new(::buffa::DEFAULT_ELEMENT_MEMORY_LIMIT);
49        <Self as ::buffa::MessageView>::decode_view_ctx(
50            buf,
51            ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit)
52                .with_element_memory(&__elem),
53        )
54    }
55    fn decode_view_with_ctx(
56        buf: &'a [u8],
57        ctx: ::buffa::DecodeContext<'_>,
58    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
59        <Self as ::buffa::MessageView>::decode_view_ctx(buf, ctx)
60    }
61    #[inline]
62    fn merge_view_field(
63        &mut self,
64        tag: ::buffa::encoding::Tag,
65        cur: &'a [u8],
66        before_tag: &'a [u8],
67        ctx: ::buffa::DecodeContext<'_>,
68    ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> {
69        let _ = ctx;
70        #[allow(unused_variables)]
71        let view = self;
72        let mut cur = cur;
73        match tag.field_number() {
74            1u32 => {
75                ::buffa::encoding::check_wire_type(
76                    tag,
77                    ::buffa::encoding::WireType::LengthDelimited,
78                )?;
79                view.name = ::buffa::types::borrow_str(&mut cur)?;
80            }
81            5u32 => {
82                ::buffa::encoding::check_wire_type(
83                    tag,
84                    ::buffa::encoding::WireType::LengthDelimited,
85                )?;
86                let __sub_ctx = ctx.descend()?;
87                let sub = ::buffa::types::borrow_bytes(&mut cur)?;
88                match view.source_context.as_mut() {
89                    Some(existing) => {
90                        ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)?
91                    }
92                    None => {
93                        view.source_context = ::buffa::MessageFieldView::set(
94                            <super::super::__buffa::view::SourceContextView as ::buffa::MessageView>::decode_view_ctx(
95                                sub,
96                                __sub_ctx,
97                            )?,
98                        );
99                    }
100                }
101            }
102            6u32 => {
103                ::buffa::encoding::check_wire_type(
104                    tag,
105                    ::buffa::encoding::WireType::Varint,
106                )?;
107                view.syntax = ::buffa::EnumValue::from(
108                    ::buffa::types::decode_int32(&mut cur)?,
109                );
110            }
111            7u32 => {
112                ::buffa::encoding::check_wire_type(
113                    tag,
114                    ::buffa::encoding::WireType::LengthDelimited,
115                )?;
116                view.edition = ::buffa::types::borrow_str(&mut cur)?;
117            }
118            2u32 => {
119                ::buffa::encoding::check_wire_type(
120                    tag,
121                    ::buffa::encoding::WireType::LengthDelimited,
122                )?;
123                let __sub_ctx = ctx.descend()?;
124                let sub = ::buffa::types::borrow_bytes(&mut cur)?;
125                ctx.register_element_memory(
126                    ::core::mem::size_of::<super::super::__buffa::view::FieldView>(),
127                )?;
128                view.fields
129                    .push(
130                        <super::super::__buffa::view::FieldView as ::buffa::MessageView>::decode_view_ctx(
131                            sub,
132                            __sub_ctx,
133                        )?,
134                    );
135            }
136            3u32 => {
137                ::buffa::encoding::check_wire_type(
138                    tag,
139                    ::buffa::encoding::WireType::LengthDelimited,
140                )?;
141                let __elem = ::buffa::types::borrow_str(&mut cur)?;
142                ctx.register_element_memory(
143                    ::buffa::__private::element_footprint(&__elem),
144                )?;
145                view.oneofs.push(__elem);
146            }
147            4u32 => {
148                ::buffa::encoding::check_wire_type(
149                    tag,
150                    ::buffa::encoding::WireType::LengthDelimited,
151                )?;
152                let __sub_ctx = ctx.descend()?;
153                let sub = ::buffa::types::borrow_bytes(&mut cur)?;
154                ctx.register_element_memory(
155                    ::core::mem::size_of::<super::super::__buffa::view::OptionView>(),
156                )?;
157                view.options
158                    .push(
159                        <super::super::__buffa::view::OptionView as ::buffa::MessageView>::decode_view_ctx(
160                            sub,
161                            __sub_ctx,
162                        )?,
163                    );
164            }
165            _ => {
166                ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?;
167                let span_len = before_tag.len() - cur.len();
168                view.__buffa_unknown_fields.push_record(before_tag, span_len, ctx)?;
169            }
170        }
171        ::core::result::Result::Ok(cur)
172    }
173    fn to_owned_message(
174        &self,
175    ) -> ::core::result::Result<super::super::Type, ::buffa::DecodeError> {
176        self.to_owned_from_source(None)
177    }
178    #[allow(clippy::useless_conversion, clippy::needless_update)]
179    fn to_owned_from_source(
180        &self,
181        __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>,
182    ) -> ::core::result::Result<super::super::Type, ::buffa::DecodeError> {
183        #[allow(unused_imports)]
184        use ::buffa::alloc::string::ToString as _;
185        let _ = __buffa_src;
186        ::core::result::Result::Ok(super::super::Type {
187            name: self.name.to_string(),
188            fields: self
189                .fields
190                .iter()
191                .map(|v| v.to_owned_from_source(__buffa_src))
192                .collect::<::core::result::Result<_, ::buffa::DecodeError>>()?,
193            oneofs: self.oneofs.iter().map(|s| s.to_string()).collect(),
194            options: self
195                .options
196                .iter()
197                .map(|v| v.to_owned_from_source(__buffa_src))
198                .collect::<::core::result::Result<_, ::buffa::DecodeError>>()?,
199            source_context: match self.source_context.as_option() {
200                Some(v) => {
201                    ::buffa::MessageField::<
202                        super::super::SourceContext,
203                        ::buffa::Inline<super::super::SourceContext>,
204                    >::some(v.to_owned_from_source(__buffa_src)?)
205                }
206                None => ::buffa::MessageField::none(),
207            },
208            syntax: self.syntax,
209            edition: self.edition.to_string(),
210            __buffa_unknown_fields: self.__buffa_unknown_fields.to_owned()?.into(),
211            ..::core::default::Default::default()
212        })
213    }
214}
215impl<'a> ::buffa::ViewEncode<'a> for TypeView<'a> {
216    #[allow(clippy::needless_borrow, clippy::let_and_return)]
217    fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 {
218        #[allow(unused_imports)]
219        use ::buffa::Enumeration as _;
220        let mut size = 0u64;
221        if !self.name.is_empty() {
222            size += 1u64 + ::buffa::types::string_encoded_len(&self.name) as u64;
223        }
224        for v in &self.fields {
225            let __slot = __cache.reserve();
226            let inner_size = v.compute_size(__cache);
227            __cache.set(__slot, inner_size);
228            size
229                += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64
230                    + inner_size as u64;
231        }
232        for v in &self.oneofs {
233            size += 1u64 + ::buffa::types::string_encoded_len(v) as u64;
234        }
235        for v in &self.options {
236            let __slot = __cache.reserve();
237            let inner_size = v.compute_size(__cache);
238            __cache.set(__slot, inner_size);
239            size
240                += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64
241                    + inner_size as u64;
242        }
243        if self.source_context.is_set() {
244            let __slot = __cache.reserve();
245            let inner_size = self.source_context.compute_size(__cache);
246            __cache.set(__slot, inner_size);
247            size
248                += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64
249                    + inner_size as u64;
250        }
251        {
252            let val = self.syntax.to_i32();
253            if val != 0 {
254                size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64;
255            }
256        }
257        if !self.edition.is_empty() {
258            size += 1u64 + ::buffa::types::string_encoded_len(&self.edition) as u64;
259        }
260        size += self.__buffa_unknown_fields.encoded_len() as u64;
261        ::buffa::saturate_size(size)
262    }
263    #[allow(clippy::needless_borrow)]
264    fn write_to(
265        &self,
266        __cache: &mut ::buffa::SizeCache,
267        buf: &mut impl ::buffa::EncodeSink,
268    ) {
269        #[allow(unused_imports)]
270        use ::buffa::Enumeration as _;
271        if !self.name.is_empty() {
272            ::buffa::types::put_string_field(1u32, &self.name, buf);
273        }
274        for v in &self.fields {
275            ::buffa::types::put_len_delimited_header(
276                2u32,
277                u64::from(__cache.consume_next()),
278                buf,
279            );
280            v.write_to(__cache, buf);
281        }
282        for v in &self.oneofs {
283            ::buffa::types::put_string_field(3u32, v, buf);
284        }
285        for v in &self.options {
286            ::buffa::types::put_len_delimited_header(
287                4u32,
288                u64::from(__cache.consume_next()),
289                buf,
290            );
291            v.write_to(__cache, buf);
292        }
293        if self.source_context.is_set() {
294            ::buffa::types::put_len_delimited_header(
295                5u32,
296                u64::from(__cache.consume_next()),
297                buf,
298            );
299            self.source_context.write_to(__cache, buf);
300        }
301        {
302            let val = self.syntax.to_i32();
303            if val != 0 {
304                ::buffa::types::put_int32_field(6u32, val, buf);
305            }
306        }
307        if !self.edition.is_empty() {
308            ::buffa::types::put_string_field(7u32, &self.edition, buf);
309        }
310        self.__buffa_unknown_fields.write_to(buf);
311    }
312}
313impl<'a> ::buffa::MessageName for TypeView<'a> {
314    const PACKAGE: &'static str = "google.protobuf";
315    const NAME: &'static str = "Type";
316    const FULL_NAME: &'static str = "google.protobuf.Type";
317    const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.Type";
318}
319::buffa::impl_default_view_instance!(TypeView);
320::buffa::impl_view_reborrow!(TypeView);
321/** Self-contained, `'static` owned view of a `Type` message.
322
323 Wraps [`::buffa::OwnedView`]`<`[`TypeView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required.
324
325 Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`TypeView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/
326#[derive(Clone, Debug)]
327pub struct TypeOwnedView(::buffa::OwnedView<TypeView<'static>>);
328impl TypeOwnedView {
329    /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer.
330    ///
331    /// The view borrows directly from the buffer's data; the buffer is
332    /// retained inside the returned handle.
333    ///
334    /// # Errors
335    ///
336    /// Returns [`::buffa::DecodeError`] if the buffer contains invalid
337    /// protobuf data.
338    pub fn decode(
339        bytes: ::buffa::bytes::Bytes,
340    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
341        ::core::result::Result::Ok(TypeOwnedView(::buffa::OwnedView::decode(bytes)?))
342    }
343    /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit,
344    /// max message size).
345    ///
346    /// # Errors
347    ///
348    /// Returns [`::buffa::DecodeError`] if the buffer is invalid or
349    /// exceeds the configured limits.
350    pub fn decode_with_options(
351        bytes: ::buffa::bytes::Bytes,
352        opts: &::buffa::DecodeOptions,
353    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
354        ::core::result::Result::Ok(
355            TypeOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?),
356        )
357    }
358    /// Build from an owned message via an encode → decode round-trip.
359    ///
360    /// # Errors
361    ///
362    /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the
363    /// message's encoded size exceeds the 2 GiB protobuf limit, or
364    /// another [`::buffa::DecodeError`] if the re-encoded bytes are
365    /// somehow invalid (should not happen for well-formed messages).
366    pub fn from_owned(
367        msg: &super::super::Type,
368    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
369        ::core::result::Result::Ok(TypeOwnedView(::buffa::OwnedView::from_owned(msg)?))
370    }
371    /// Borrow the full [`TypeView`] with its lifetime tied to `&self`.
372    #[must_use]
373    pub fn view(&self) -> &TypeView<'_> {
374        self.0.reborrow()
375    }
376    /// Convert to the owned message type.
377    ///
378    /// Infallible: this type's constructors wire-decode their
379    /// buffer, and a view produced by wire decoding always
380    /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`],
381    /// whose contract also governs handles converted from a raw
382    /// [`::buffa::OwnedView`].
383    #[must_use]
384    pub fn to_owned_message(&self) -> super::super::Type {
385        self.0.to_owned_message()
386    }
387    /// The underlying bytes buffer.
388    #[must_use]
389    pub fn bytes(&self) -> &::buffa::bytes::Bytes {
390        self.0.bytes()
391    }
392    /// Consume the handle, returning the underlying bytes buffer.
393    #[must_use]
394    pub fn into_bytes(self) -> ::buffa::bytes::Bytes {
395        self.0.into_bytes()
396    }
397    /// The fully qualified message name.
398    ///
399    /// Field 1: `name`
400    #[must_use]
401    pub fn name(&self) -> &'_ str {
402        self.0.reborrow().name
403    }
404    /// The list of fields.
405    ///
406    /// Field 2: `fields`
407    #[must_use]
408    pub fn fields(
409        &self,
410    ) -> &::buffa::RepeatedView<'_, super::super::__buffa::view::FieldView<'_>> {
411        &self.0.reborrow().fields
412    }
413    /// The list of types appearing in `oneof` definitions in this type.
414    ///
415    /// Field 3: `oneofs`
416    #[must_use]
417    pub fn oneofs(&self) -> &::buffa::RepeatedView<'_, &'_ str> {
418        &self.0.reborrow().oneofs
419    }
420    /// The protocol buffer options.
421    ///
422    /// Field 4: `options`
423    #[must_use]
424    pub fn options(
425        &self,
426    ) -> &::buffa::RepeatedView<'_, super::super::__buffa::view::OptionView<'_>> {
427        &self.0.reborrow().options
428    }
429    /// The source context.
430    ///
431    /// Field 5: `source_context`
432    #[must_use]
433    pub fn source_context(
434        &self,
435    ) -> &::buffa::MessageFieldView<super::super::__buffa::view::SourceContextView<'_>> {
436        &self.0.reborrow().source_context
437    }
438    /// The source syntax.
439    ///
440    /// Field 6: `syntax`
441    #[must_use]
442    pub fn syntax(&self) -> ::buffa::EnumValue<super::super::Syntax> {
443        self.0.reborrow().syntax
444    }
445    /// The source edition string, only valid when syntax is SYNTAX_EDITIONS.
446    ///
447    /// Field 7: `edition`
448    #[must_use]
449    pub fn edition(&self) -> &'_ str {
450        self.0.reborrow().edition
451    }
452}
453impl ::core::convert::From<::buffa::OwnedView<TypeView<'static>>> for TypeOwnedView {
454    fn from(inner: ::buffa::OwnedView<TypeView<'static>>) -> Self {
455        TypeOwnedView(inner)
456    }
457}
458impl ::core::convert::From<TypeOwnedView> for ::buffa::OwnedView<TypeView<'static>> {
459    fn from(wrapper: TypeOwnedView) -> Self {
460        wrapper.0
461    }
462}
463impl ::core::convert::AsRef<::buffa::OwnedView<TypeView<'static>>> for TypeOwnedView {
464    fn as_ref(&self) -> &::buffa::OwnedView<TypeView<'static>> {
465        &self.0
466    }
467}
468impl ::buffa::HasMessageView for super::super::Type {
469    type View<'a> = TypeView<'a>;
470    type ViewHandle = TypeOwnedView;
471}
472#[cfg(feature = "reflect")]
473const _: () = {
474    impl<'a> ::buffa_descriptor::reflect::ReflectMessage for TypeView<'a> {
475        fn message_descriptor(&self) -> &::buffa_descriptor::MessageDescriptor {
476            super::super::__buffa::reflect::descriptor_pool()
477                .message(Self::__buffa_reflect_message_index())
478        }
479        fn pool(
480            &self,
481        ) -> &::buffa::alloc::sync::Arc<::buffa_descriptor::DescriptorPool> {
482            super::super::__buffa::reflect::descriptor_pool()
483        }
484        fn get(
485            &self,
486            field: &::buffa_descriptor::FieldDescriptor,
487        ) -> ::buffa_descriptor::reflect::ValueRef<'_> {
488            #[allow(unused_imports)]
489            use ::buffa::Enumeration as _;
490            match field.number() {
491                1u32 => ::buffa_descriptor::reflect::ValueRef::String(self.name),
492                2u32 => ::buffa_descriptor::reflect::ValueRef::List(&self.fields),
493                3u32 => ::buffa_descriptor::reflect::ValueRef::List(&self.oneofs),
494                4u32 => ::buffa_descriptor::reflect::ValueRef::List(&self.options),
495                5u32 => {
496                    ::buffa_descriptor::reflect::ValueRef::Message(
497                        ::buffa_descriptor::reflect::ReflectCow::Borrowed(
498                            &*self.source_context,
499                        ),
500                    )
501                }
502                6u32 => {
503                    ::buffa_descriptor::reflect::ValueRef::EnumNumber(
504                        self.syntax.to_i32(),
505                    )
506                }
507                7u32 => ::buffa_descriptor::reflect::ValueRef::String(self.edition),
508                _ => {
509                    ::core::debug_assert!(
510                        false,
511                        "field number {} is not a member of this view's reflect get()",
512                        field.number(),
513                    );
514                    ::buffa_descriptor::reflect::ValueRef::Bool(false)
515                }
516            }
517        }
518        fn has(&self, field: &::buffa_descriptor::FieldDescriptor) -> bool {
519            match field.number() {
520                1u32 => !self.name.is_empty(),
521                2u32 => !::buffa::RepeatedView::is_empty(&self.fields),
522                3u32 => !::buffa::RepeatedView::is_empty(&self.oneofs),
523                4u32 => !::buffa::RepeatedView::is_empty(&self.options),
524                5u32 => self.source_context.is_set(),
525                6u32 => self.syntax.to_i32() != 0,
526                7u32 => !self.edition.is_empty(),
527                _ => false,
528            }
529        }
530        fn for_each_set(
531            &self,
532            f: &mut dyn ::core::ops::FnMut(
533                &::buffa_descriptor::FieldDescriptor,
534                ::buffa_descriptor::reflect::ValueRef<'_>,
535            ),
536        ) {
537            let md = ::buffa_descriptor::reflect::ReflectMessage::message_descriptor(
538                self,
539            );
540            for fd in md.fields() {
541                if ::buffa_descriptor::reflect::ReflectMessage::has(self, fd) {
542                    f(fd, ::buffa_descriptor::reflect::ReflectMessage::get(self, fd));
543                }
544            }
545        }
546        fn to_dynamic(&self) -> ::buffa_descriptor::reflect::DynamicMessage {
547            let bytes = ::buffa::ViewEncode::encode_to_vec(self);
548            let options = ::buffa::DecodeOptions::new()
549                .with_element_memory_limit(
550                    bytes
551                        .len()
552                        .saturating_mul(128)
553                        .max(::buffa::DEFAULT_ELEMENT_MEMORY_LIMIT),
554                )
555                .with_unknown_field_limit(
556                    bytes.len().max(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT),
557                );
558            ::buffa_descriptor::reflect::DynamicMessage::decode_with_options(
559                    ::buffa::alloc::sync::Arc::clone(
560                        super::super::__buffa::reflect::descriptor_pool(),
561                    ),
562                    Self::__buffa_reflect_message_index(),
563                    &bytes,
564                    &options,
565                )
566                .expect("view re-encodes to bytes decodable against its own descriptor")
567        }
568    }
569    impl<'a> ::buffa_descriptor::reflect::ReflectElement for TypeView<'a> {
570        fn as_value_ref(&self) -> ::buffa_descriptor::reflect::ValueRef<'_> {
571            ::buffa_descriptor::reflect::ValueRef::Message(
572                ::buffa_descriptor::reflect::ReflectCow::Borrowed(self),
573            )
574        }
575    }
576    impl<'a> TypeView<'a> {
577        /// Memoized `MessageIndex` for this view's message type, resolved
578        /// once against the package's embedded descriptor pool. An inherent
579        /// associated fn (not a free fn) so sibling views in the same module
580        /// do not collide.
581        #[doc(hidden)]
582        fn __buffa_reflect_message_index() -> ::buffa_descriptor::MessageIndex {
583            static IDX: ::std::sync::OnceLock<::buffa_descriptor::MessageIndex> = ::std::sync::OnceLock::new();
584            *IDX
585                .get_or_init(|| {
586                    super::super::__buffa::reflect::descriptor_pool()
587                        .message_index(<Self as ::buffa::MessageName>::FULL_NAME)
588                        .expect(
589                            "generated view type is registered in the embedded descriptor pool",
590                        )
591                })
592        }
593    }
594};
595/// A single field of a message type.
596///
597/// New usages of this message as an alternative to FieldDescriptorProto are
598/// strongly discouraged. This message does not reliability preserve all
599/// information necessary to model the schema and preserve semantics. Instead
600/// make use of FileDescriptorSet which preserves the necessary information.
601#[derive(Clone, Debug, Default)]
602pub struct FieldView<'a> {
603    /// The field type.
604    ///
605    /// Field 1: `kind`
606    pub kind: ::buffa::EnumValue<super::super::field::Kind>,
607    /// The field cardinality.
608    ///
609    /// Field 2: `cardinality`
610    pub cardinality: ::buffa::EnumValue<super::super::field::Cardinality>,
611    /// The field number.
612    ///
613    /// Field 3: `number`
614    pub number: i32,
615    /// The field name.
616    ///
617    /// Field 4: `name`
618    pub name: &'a str,
619    /// The field type URL, without the scheme, for message or enumeration
620    /// types. Example: `"type.googleapis.com/google.protobuf.Timestamp"`.
621    ///
622    /// Field 6: `type_url`
623    pub type_url: &'a str,
624    /// The index of the field type in `Type.oneofs`, for message or enumeration
625    /// types. The first type has index 1; zero means the type is not in the list.
626    ///
627    /// Field 7: `oneof_index`
628    pub oneof_index: i32,
629    /// Whether to use alternative packed wire representation.
630    ///
631    /// Field 8: `packed`
632    pub packed: bool,
633    /// The protocol buffer options.
634    ///
635    /// Field 9: `options`
636    pub options: ::buffa::RepeatedView<'a, super::super::__buffa::view::OptionView<'a>>,
637    /// The field JSON name.
638    ///
639    /// Field 10: `json_name`
640    pub json_name: &'a str,
641    /// The string value of the default value of this field. Proto2 syntax only.
642    ///
643    /// Field 11: `default_value`
644    pub default_value: &'a str,
645    pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
646}
647impl<'a> ::buffa::MessageView<'a> for FieldView<'a> {
648    type Owned = super::super::Field;
649    fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
650        let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT);
651        let __elem = ::core::cell::Cell::new(::buffa::DEFAULT_ELEMENT_MEMORY_LIMIT);
652        <Self as ::buffa::MessageView>::decode_view_ctx(
653            buf,
654            ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit)
655                .with_element_memory(&__elem),
656        )
657    }
658    fn decode_view_with_ctx(
659        buf: &'a [u8],
660        ctx: ::buffa::DecodeContext<'_>,
661    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
662        <Self as ::buffa::MessageView>::decode_view_ctx(buf, ctx)
663    }
664    #[inline]
665    fn merge_view_field(
666        &mut self,
667        tag: ::buffa::encoding::Tag,
668        cur: &'a [u8],
669        before_tag: &'a [u8],
670        ctx: ::buffa::DecodeContext<'_>,
671    ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> {
672        let _ = ctx;
673        #[allow(unused_variables)]
674        let view = self;
675        let mut cur = cur;
676        match tag.field_number() {
677            1u32 => {
678                ::buffa::encoding::check_wire_type(
679                    tag,
680                    ::buffa::encoding::WireType::Varint,
681                )?;
682                view.kind = ::buffa::EnumValue::from(
683                    ::buffa::types::decode_int32(&mut cur)?,
684                );
685            }
686            2u32 => {
687                ::buffa::encoding::check_wire_type(
688                    tag,
689                    ::buffa::encoding::WireType::Varint,
690                )?;
691                view.cardinality = ::buffa::EnumValue::from(
692                    ::buffa::types::decode_int32(&mut cur)?,
693                );
694            }
695            3u32 => {
696                ::buffa::encoding::check_wire_type(
697                    tag,
698                    ::buffa::encoding::WireType::Varint,
699                )?;
700                view.number = ::buffa::types::decode_int32(&mut cur)?;
701            }
702            4u32 => {
703                ::buffa::encoding::check_wire_type(
704                    tag,
705                    ::buffa::encoding::WireType::LengthDelimited,
706                )?;
707                view.name = ::buffa::types::borrow_str(&mut cur)?;
708            }
709            6u32 => {
710                ::buffa::encoding::check_wire_type(
711                    tag,
712                    ::buffa::encoding::WireType::LengthDelimited,
713                )?;
714                view.type_url = ::buffa::types::borrow_str(&mut cur)?;
715            }
716            7u32 => {
717                ::buffa::encoding::check_wire_type(
718                    tag,
719                    ::buffa::encoding::WireType::Varint,
720                )?;
721                view.oneof_index = ::buffa::types::decode_int32(&mut cur)?;
722            }
723            8u32 => {
724                ::buffa::encoding::check_wire_type(
725                    tag,
726                    ::buffa::encoding::WireType::Varint,
727                )?;
728                view.packed = ::buffa::types::decode_bool(&mut cur)?;
729            }
730            10u32 => {
731                ::buffa::encoding::check_wire_type(
732                    tag,
733                    ::buffa::encoding::WireType::LengthDelimited,
734                )?;
735                view.json_name = ::buffa::types::borrow_str(&mut cur)?;
736            }
737            11u32 => {
738                ::buffa::encoding::check_wire_type(
739                    tag,
740                    ::buffa::encoding::WireType::LengthDelimited,
741                )?;
742                view.default_value = ::buffa::types::borrow_str(&mut cur)?;
743            }
744            9u32 => {
745                ::buffa::encoding::check_wire_type(
746                    tag,
747                    ::buffa::encoding::WireType::LengthDelimited,
748                )?;
749                let __sub_ctx = ctx.descend()?;
750                let sub = ::buffa::types::borrow_bytes(&mut cur)?;
751                ctx.register_element_memory(
752                    ::core::mem::size_of::<super::super::__buffa::view::OptionView>(),
753                )?;
754                view.options
755                    .push(
756                        <super::super::__buffa::view::OptionView as ::buffa::MessageView>::decode_view_ctx(
757                            sub,
758                            __sub_ctx,
759                        )?,
760                    );
761            }
762            _ => {
763                ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?;
764                let span_len = before_tag.len() - cur.len();
765                view.__buffa_unknown_fields.push_record(before_tag, span_len, ctx)?;
766            }
767        }
768        ::core::result::Result::Ok(cur)
769    }
770    fn to_owned_message(
771        &self,
772    ) -> ::core::result::Result<super::super::Field, ::buffa::DecodeError> {
773        self.to_owned_from_source(None)
774    }
775    #[allow(clippy::useless_conversion, clippy::needless_update)]
776    fn to_owned_from_source(
777        &self,
778        __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>,
779    ) -> ::core::result::Result<super::super::Field, ::buffa::DecodeError> {
780        #[allow(unused_imports)]
781        use ::buffa::alloc::string::ToString as _;
782        let _ = __buffa_src;
783        ::core::result::Result::Ok(super::super::Field {
784            kind: self.kind,
785            cardinality: self.cardinality,
786            number: self.number,
787            name: self.name.to_string(),
788            type_url: self.type_url.to_string(),
789            oneof_index: self.oneof_index,
790            packed: self.packed,
791            options: self
792                .options
793                .iter()
794                .map(|v| v.to_owned_from_source(__buffa_src))
795                .collect::<::core::result::Result<_, ::buffa::DecodeError>>()?,
796            json_name: self.json_name.to_string(),
797            default_value: self.default_value.to_string(),
798            __buffa_unknown_fields: self.__buffa_unknown_fields.to_owned()?.into(),
799            ..::core::default::Default::default()
800        })
801    }
802}
803impl<'a> ::buffa::ViewEncode<'a> for FieldView<'a> {
804    #[allow(clippy::needless_borrow, clippy::let_and_return)]
805    fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 {
806        #[allow(unused_imports)]
807        use ::buffa::Enumeration as _;
808        let mut size = 0u64;
809        {
810            let val = self.kind.to_i32();
811            if val != 0 {
812                size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64;
813            }
814        }
815        {
816            let val = self.cardinality.to_i32();
817            if val != 0 {
818                size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64;
819            }
820        }
821        if self.number != 0i32 {
822            size += 1u64 + ::buffa::types::int32_encoded_len(self.number) as u64;
823        }
824        if !self.name.is_empty() {
825            size += 1u64 + ::buffa::types::string_encoded_len(&self.name) as u64;
826        }
827        if !self.type_url.is_empty() {
828            size += 1u64 + ::buffa::types::string_encoded_len(&self.type_url) as u64;
829        }
830        if self.oneof_index != 0i32 {
831            size += 1u64 + ::buffa::types::int32_encoded_len(self.oneof_index) as u64;
832        }
833        if self.packed {
834            size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64;
835        }
836        for v in &self.options {
837            let __slot = __cache.reserve();
838            let inner_size = v.compute_size(__cache);
839            __cache.set(__slot, inner_size);
840            size
841                += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64
842                    + inner_size as u64;
843        }
844        if !self.json_name.is_empty() {
845            size += 1u64 + ::buffa::types::string_encoded_len(&self.json_name) as u64;
846        }
847        if !self.default_value.is_empty() {
848            size
849                += 1u64 + ::buffa::types::string_encoded_len(&self.default_value) as u64;
850        }
851        size += self.__buffa_unknown_fields.encoded_len() as u64;
852        ::buffa::saturate_size(size)
853    }
854    #[allow(clippy::needless_borrow)]
855    fn write_to(
856        &self,
857        __cache: &mut ::buffa::SizeCache,
858        buf: &mut impl ::buffa::EncodeSink,
859    ) {
860        #[allow(unused_imports)]
861        use ::buffa::Enumeration as _;
862        {
863            let val = self.kind.to_i32();
864            if val != 0 {
865                ::buffa::types::put_int32_field(1u32, val, buf);
866            }
867        }
868        {
869            let val = self.cardinality.to_i32();
870            if val != 0 {
871                ::buffa::types::put_int32_field(2u32, val, buf);
872            }
873        }
874        if self.number != 0i32 {
875            ::buffa::types::put_int32_field(3u32, self.number, buf);
876        }
877        if !self.name.is_empty() {
878            ::buffa::types::put_string_field(4u32, &self.name, buf);
879        }
880        if !self.type_url.is_empty() {
881            ::buffa::types::put_string_field(6u32, &self.type_url, buf);
882        }
883        if self.oneof_index != 0i32 {
884            ::buffa::types::put_int32_field(7u32, self.oneof_index, buf);
885        }
886        if self.packed {
887            ::buffa::types::put_bool_field(8u32, self.packed, buf);
888        }
889        for v in &self.options {
890            ::buffa::types::put_len_delimited_header(
891                9u32,
892                u64::from(__cache.consume_next()),
893                buf,
894            );
895            v.write_to(__cache, buf);
896        }
897        if !self.json_name.is_empty() {
898            ::buffa::types::put_string_field(10u32, &self.json_name, buf);
899        }
900        if !self.default_value.is_empty() {
901            ::buffa::types::put_string_field(11u32, &self.default_value, buf);
902        }
903        self.__buffa_unknown_fields.write_to(buf);
904    }
905}
906impl<'a> ::buffa::MessageName for FieldView<'a> {
907    const PACKAGE: &'static str = "google.protobuf";
908    const NAME: &'static str = "Field";
909    const FULL_NAME: &'static str = "google.protobuf.Field";
910    const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.Field";
911}
912::buffa::impl_default_view_instance!(FieldView);
913::buffa::impl_view_reborrow!(FieldView);
914/** Self-contained, `'static` owned view of a `Field` message.
915
916 Wraps [`::buffa::OwnedView`]`<`[`FieldView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required.
917
918 Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`FieldView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/
919#[derive(Clone, Debug)]
920pub struct FieldOwnedView(::buffa::OwnedView<FieldView<'static>>);
921impl FieldOwnedView {
922    /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer.
923    ///
924    /// The view borrows directly from the buffer's data; the buffer is
925    /// retained inside the returned handle.
926    ///
927    /// # Errors
928    ///
929    /// Returns [`::buffa::DecodeError`] if the buffer contains invalid
930    /// protobuf data.
931    pub fn decode(
932        bytes: ::buffa::bytes::Bytes,
933    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
934        ::core::result::Result::Ok(FieldOwnedView(::buffa::OwnedView::decode(bytes)?))
935    }
936    /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit,
937    /// max message size).
938    ///
939    /// # Errors
940    ///
941    /// Returns [`::buffa::DecodeError`] if the buffer is invalid or
942    /// exceeds the configured limits.
943    pub fn decode_with_options(
944        bytes: ::buffa::bytes::Bytes,
945        opts: &::buffa::DecodeOptions,
946    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
947        ::core::result::Result::Ok(
948            FieldOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?),
949        )
950    }
951    /// Build from an owned message via an encode → decode round-trip.
952    ///
953    /// # Errors
954    ///
955    /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the
956    /// message's encoded size exceeds the 2 GiB protobuf limit, or
957    /// another [`::buffa::DecodeError`] if the re-encoded bytes are
958    /// somehow invalid (should not happen for well-formed messages).
959    pub fn from_owned(
960        msg: &super::super::Field,
961    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
962        ::core::result::Result::Ok(FieldOwnedView(::buffa::OwnedView::from_owned(msg)?))
963    }
964    /// Borrow the full [`FieldView`] with its lifetime tied to `&self`.
965    #[must_use]
966    pub fn view(&self) -> &FieldView<'_> {
967        self.0.reborrow()
968    }
969    /// Convert to the owned message type.
970    ///
971    /// Infallible: this type's constructors wire-decode their
972    /// buffer, and a view produced by wire decoding always
973    /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`],
974    /// whose contract also governs handles converted from a raw
975    /// [`::buffa::OwnedView`].
976    #[must_use]
977    pub fn to_owned_message(&self) -> super::super::Field {
978        self.0.to_owned_message()
979    }
980    /// The underlying bytes buffer.
981    #[must_use]
982    pub fn bytes(&self) -> &::buffa::bytes::Bytes {
983        self.0.bytes()
984    }
985    /// Consume the handle, returning the underlying bytes buffer.
986    #[must_use]
987    pub fn into_bytes(self) -> ::buffa::bytes::Bytes {
988        self.0.into_bytes()
989    }
990    /// The field type.
991    ///
992    /// Field 1: `kind`
993    #[must_use]
994    pub fn kind(&self) -> ::buffa::EnumValue<super::super::field::Kind> {
995        self.0.reborrow().kind
996    }
997    /// The field cardinality.
998    ///
999    /// Field 2: `cardinality`
1000    #[must_use]
1001    pub fn cardinality(&self) -> ::buffa::EnumValue<super::super::field::Cardinality> {
1002        self.0.reborrow().cardinality
1003    }
1004    /// The field number.
1005    ///
1006    /// Field 3: `number`
1007    #[must_use]
1008    pub fn number(&self) -> i32 {
1009        self.0.reborrow().number
1010    }
1011    /// The field name.
1012    ///
1013    /// Field 4: `name`
1014    #[must_use]
1015    pub fn name(&self) -> &'_ str {
1016        self.0.reborrow().name
1017    }
1018    /// The field type URL, without the scheme, for message or enumeration
1019    /// types. Example: `"type.googleapis.com/google.protobuf.Timestamp"`.
1020    ///
1021    /// Field 6: `type_url`
1022    #[must_use]
1023    pub fn type_url(&self) -> &'_ str {
1024        self.0.reborrow().type_url
1025    }
1026    /// The index of the field type in `Type.oneofs`, for message or enumeration
1027    /// types. The first type has index 1; zero means the type is not in the list.
1028    ///
1029    /// Field 7: `oneof_index`
1030    #[must_use]
1031    pub fn oneof_index(&self) -> i32 {
1032        self.0.reborrow().oneof_index
1033    }
1034    /// Whether to use alternative packed wire representation.
1035    ///
1036    /// Field 8: `packed`
1037    #[must_use]
1038    pub fn packed(&self) -> bool {
1039        self.0.reborrow().packed
1040    }
1041    /// The protocol buffer options.
1042    ///
1043    /// Field 9: `options`
1044    #[must_use]
1045    pub fn options(
1046        &self,
1047    ) -> &::buffa::RepeatedView<'_, super::super::__buffa::view::OptionView<'_>> {
1048        &self.0.reborrow().options
1049    }
1050    /// The field JSON name.
1051    ///
1052    /// Field 10: `json_name`
1053    #[must_use]
1054    pub fn json_name(&self) -> &'_ str {
1055        self.0.reborrow().json_name
1056    }
1057    /// The string value of the default value of this field. Proto2 syntax only.
1058    ///
1059    /// Field 11: `default_value`
1060    #[must_use]
1061    pub fn default_value(&self) -> &'_ str {
1062        self.0.reborrow().default_value
1063    }
1064}
1065impl ::core::convert::From<::buffa::OwnedView<FieldView<'static>>> for FieldOwnedView {
1066    fn from(inner: ::buffa::OwnedView<FieldView<'static>>) -> Self {
1067        FieldOwnedView(inner)
1068    }
1069}
1070impl ::core::convert::From<FieldOwnedView> for ::buffa::OwnedView<FieldView<'static>> {
1071    fn from(wrapper: FieldOwnedView) -> Self {
1072        wrapper.0
1073    }
1074}
1075impl ::core::convert::AsRef<::buffa::OwnedView<FieldView<'static>>> for FieldOwnedView {
1076    fn as_ref(&self) -> &::buffa::OwnedView<FieldView<'static>> {
1077        &self.0
1078    }
1079}
1080impl ::buffa::HasMessageView for super::super::Field {
1081    type View<'a> = FieldView<'a>;
1082    type ViewHandle = FieldOwnedView;
1083}
1084#[cfg(feature = "reflect")]
1085const _: () = {
1086    impl<'a> ::buffa_descriptor::reflect::ReflectMessage for FieldView<'a> {
1087        fn message_descriptor(&self) -> &::buffa_descriptor::MessageDescriptor {
1088            super::super::__buffa::reflect::descriptor_pool()
1089                .message(Self::__buffa_reflect_message_index())
1090        }
1091        fn pool(
1092            &self,
1093        ) -> &::buffa::alloc::sync::Arc<::buffa_descriptor::DescriptorPool> {
1094            super::super::__buffa::reflect::descriptor_pool()
1095        }
1096        fn get(
1097            &self,
1098            field: &::buffa_descriptor::FieldDescriptor,
1099        ) -> ::buffa_descriptor::reflect::ValueRef<'_> {
1100            #[allow(unused_imports)]
1101            use ::buffa::Enumeration as _;
1102            match field.number() {
1103                1u32 => {
1104                    ::buffa_descriptor::reflect::ValueRef::EnumNumber(self.kind.to_i32())
1105                }
1106                2u32 => {
1107                    ::buffa_descriptor::reflect::ValueRef::EnumNumber(
1108                        self.cardinality.to_i32(),
1109                    )
1110                }
1111                3u32 => ::buffa_descriptor::reflect::ValueRef::I32(self.number),
1112                4u32 => ::buffa_descriptor::reflect::ValueRef::String(self.name),
1113                6u32 => ::buffa_descriptor::reflect::ValueRef::String(self.type_url),
1114                7u32 => ::buffa_descriptor::reflect::ValueRef::I32(self.oneof_index),
1115                8u32 => ::buffa_descriptor::reflect::ValueRef::Bool(self.packed),
1116                9u32 => ::buffa_descriptor::reflect::ValueRef::List(&self.options),
1117                10u32 => ::buffa_descriptor::reflect::ValueRef::String(self.json_name),
1118                11u32 => {
1119                    ::buffa_descriptor::reflect::ValueRef::String(self.default_value)
1120                }
1121                _ => {
1122                    ::core::debug_assert!(
1123                        false,
1124                        "field number {} is not a member of this view's reflect get()",
1125                        field.number(),
1126                    );
1127                    ::buffa_descriptor::reflect::ValueRef::Bool(false)
1128                }
1129            }
1130        }
1131        fn has(&self, field: &::buffa_descriptor::FieldDescriptor) -> bool {
1132            match field.number() {
1133                1u32 => self.kind.to_i32() != 0,
1134                2u32 => self.cardinality.to_i32() != 0,
1135                3u32 => self.number != 0,
1136                4u32 => !self.name.is_empty(),
1137                6u32 => !self.type_url.is_empty(),
1138                7u32 => self.oneof_index != 0,
1139                8u32 => self.packed,
1140                9u32 => !::buffa::RepeatedView::is_empty(&self.options),
1141                10u32 => !self.json_name.is_empty(),
1142                11u32 => !self.default_value.is_empty(),
1143                _ => false,
1144            }
1145        }
1146        fn for_each_set(
1147            &self,
1148            f: &mut dyn ::core::ops::FnMut(
1149                &::buffa_descriptor::FieldDescriptor,
1150                ::buffa_descriptor::reflect::ValueRef<'_>,
1151            ),
1152        ) {
1153            let md = ::buffa_descriptor::reflect::ReflectMessage::message_descriptor(
1154                self,
1155            );
1156            for fd in md.fields() {
1157                if ::buffa_descriptor::reflect::ReflectMessage::has(self, fd) {
1158                    f(fd, ::buffa_descriptor::reflect::ReflectMessage::get(self, fd));
1159                }
1160            }
1161        }
1162        fn to_dynamic(&self) -> ::buffa_descriptor::reflect::DynamicMessage {
1163            let bytes = ::buffa::ViewEncode::encode_to_vec(self);
1164            let options = ::buffa::DecodeOptions::new()
1165                .with_element_memory_limit(
1166                    bytes
1167                        .len()
1168                        .saturating_mul(128)
1169                        .max(::buffa::DEFAULT_ELEMENT_MEMORY_LIMIT),
1170                )
1171                .with_unknown_field_limit(
1172                    bytes.len().max(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT),
1173                );
1174            ::buffa_descriptor::reflect::DynamicMessage::decode_with_options(
1175                    ::buffa::alloc::sync::Arc::clone(
1176                        super::super::__buffa::reflect::descriptor_pool(),
1177                    ),
1178                    Self::__buffa_reflect_message_index(),
1179                    &bytes,
1180                    &options,
1181                )
1182                .expect("view re-encodes to bytes decodable against its own descriptor")
1183        }
1184    }
1185    impl<'a> ::buffa_descriptor::reflect::ReflectElement for FieldView<'a> {
1186        fn as_value_ref(&self) -> ::buffa_descriptor::reflect::ValueRef<'_> {
1187            ::buffa_descriptor::reflect::ValueRef::Message(
1188                ::buffa_descriptor::reflect::ReflectCow::Borrowed(self),
1189            )
1190        }
1191    }
1192    impl<'a> FieldView<'a> {
1193        /// Memoized `MessageIndex` for this view's message type, resolved
1194        /// once against the package's embedded descriptor pool. An inherent
1195        /// associated fn (not a free fn) so sibling views in the same module
1196        /// do not collide.
1197        #[doc(hidden)]
1198        fn __buffa_reflect_message_index() -> ::buffa_descriptor::MessageIndex {
1199            static IDX: ::std::sync::OnceLock<::buffa_descriptor::MessageIndex> = ::std::sync::OnceLock::new();
1200            *IDX
1201                .get_or_init(|| {
1202                    super::super::__buffa::reflect::descriptor_pool()
1203                        .message_index(<Self as ::buffa::MessageName>::FULL_NAME)
1204                        .expect(
1205                            "generated view type is registered in the embedded descriptor pool",
1206                        )
1207                })
1208        }
1209    }
1210};
1211/// Enum type definition.
1212///
1213/// New usages of this message as an alternative to EnumDescriptorProto are
1214/// strongly discouraged. This message does not reliability preserve all
1215/// information necessary to model the schema and preserve semantics. Instead
1216/// make use of FileDescriptorSet which preserves the necessary information.
1217#[derive(Clone, Debug, Default)]
1218pub struct EnumView<'a> {
1219    /// Enum type name.
1220    ///
1221    /// Field 1: `name`
1222    pub name: &'a str,
1223    /// Enum value definitions.
1224    ///
1225    /// Field 2: `enumvalue`
1226    pub enumvalue: ::buffa::RepeatedView<
1227        'a,
1228        super::super::__buffa::view::EnumValueView<'a>,
1229    >,
1230    /// Protocol buffer options.
1231    ///
1232    /// Field 3: `options`
1233    pub options: ::buffa::RepeatedView<'a, super::super::__buffa::view::OptionView<'a>>,
1234    /// The source context.
1235    ///
1236    /// Field 4: `source_context`
1237    pub source_context: ::buffa::MessageFieldView<
1238        super::super::__buffa::view::SourceContextView<'a>,
1239    >,
1240    /// The source syntax.
1241    ///
1242    /// Field 5: `syntax`
1243    pub syntax: ::buffa::EnumValue<super::super::Syntax>,
1244    /// The source edition string, only valid when syntax is SYNTAX_EDITIONS.
1245    ///
1246    /// Field 6: `edition`
1247    pub edition: &'a str,
1248    pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
1249}
1250impl<'a> ::buffa::MessageView<'a> for EnumView<'a> {
1251    type Owned = super::super::Enum;
1252    fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
1253        let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT);
1254        let __elem = ::core::cell::Cell::new(::buffa::DEFAULT_ELEMENT_MEMORY_LIMIT);
1255        <Self as ::buffa::MessageView>::decode_view_ctx(
1256            buf,
1257            ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit)
1258                .with_element_memory(&__elem),
1259        )
1260    }
1261    fn decode_view_with_ctx(
1262        buf: &'a [u8],
1263        ctx: ::buffa::DecodeContext<'_>,
1264    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
1265        <Self as ::buffa::MessageView>::decode_view_ctx(buf, ctx)
1266    }
1267    #[inline]
1268    fn merge_view_field(
1269        &mut self,
1270        tag: ::buffa::encoding::Tag,
1271        cur: &'a [u8],
1272        before_tag: &'a [u8],
1273        ctx: ::buffa::DecodeContext<'_>,
1274    ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> {
1275        let _ = ctx;
1276        #[allow(unused_variables)]
1277        let view = self;
1278        let mut cur = cur;
1279        match tag.field_number() {
1280            1u32 => {
1281                ::buffa::encoding::check_wire_type(
1282                    tag,
1283                    ::buffa::encoding::WireType::LengthDelimited,
1284                )?;
1285                view.name = ::buffa::types::borrow_str(&mut cur)?;
1286            }
1287            4u32 => {
1288                ::buffa::encoding::check_wire_type(
1289                    tag,
1290                    ::buffa::encoding::WireType::LengthDelimited,
1291                )?;
1292                let __sub_ctx = ctx.descend()?;
1293                let sub = ::buffa::types::borrow_bytes(&mut cur)?;
1294                match view.source_context.as_mut() {
1295                    Some(existing) => {
1296                        ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)?
1297                    }
1298                    None => {
1299                        view.source_context = ::buffa::MessageFieldView::set(
1300                            <super::super::__buffa::view::SourceContextView as ::buffa::MessageView>::decode_view_ctx(
1301                                sub,
1302                                __sub_ctx,
1303                            )?,
1304                        );
1305                    }
1306                }
1307            }
1308            5u32 => {
1309                ::buffa::encoding::check_wire_type(
1310                    tag,
1311                    ::buffa::encoding::WireType::Varint,
1312                )?;
1313                view.syntax = ::buffa::EnumValue::from(
1314                    ::buffa::types::decode_int32(&mut cur)?,
1315                );
1316            }
1317            6u32 => {
1318                ::buffa::encoding::check_wire_type(
1319                    tag,
1320                    ::buffa::encoding::WireType::LengthDelimited,
1321                )?;
1322                view.edition = ::buffa::types::borrow_str(&mut cur)?;
1323            }
1324            2u32 => {
1325                ::buffa::encoding::check_wire_type(
1326                    tag,
1327                    ::buffa::encoding::WireType::LengthDelimited,
1328                )?;
1329                let __sub_ctx = ctx.descend()?;
1330                let sub = ::buffa::types::borrow_bytes(&mut cur)?;
1331                ctx.register_element_memory(
1332                    ::core::mem::size_of::<super::super::__buffa::view::EnumValueView>(),
1333                )?;
1334                view.enumvalue
1335                    .push(
1336                        <super::super::__buffa::view::EnumValueView as ::buffa::MessageView>::decode_view_ctx(
1337                            sub,
1338                            __sub_ctx,
1339                        )?,
1340                    );
1341            }
1342            3u32 => {
1343                ::buffa::encoding::check_wire_type(
1344                    tag,
1345                    ::buffa::encoding::WireType::LengthDelimited,
1346                )?;
1347                let __sub_ctx = ctx.descend()?;
1348                let sub = ::buffa::types::borrow_bytes(&mut cur)?;
1349                ctx.register_element_memory(
1350                    ::core::mem::size_of::<super::super::__buffa::view::OptionView>(),
1351                )?;
1352                view.options
1353                    .push(
1354                        <super::super::__buffa::view::OptionView as ::buffa::MessageView>::decode_view_ctx(
1355                            sub,
1356                            __sub_ctx,
1357                        )?,
1358                    );
1359            }
1360            _ => {
1361                ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?;
1362                let span_len = before_tag.len() - cur.len();
1363                view.__buffa_unknown_fields.push_record(before_tag, span_len, ctx)?;
1364            }
1365        }
1366        ::core::result::Result::Ok(cur)
1367    }
1368    fn to_owned_message(
1369        &self,
1370    ) -> ::core::result::Result<super::super::Enum, ::buffa::DecodeError> {
1371        self.to_owned_from_source(None)
1372    }
1373    #[allow(clippy::useless_conversion, clippy::needless_update)]
1374    fn to_owned_from_source(
1375        &self,
1376        __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>,
1377    ) -> ::core::result::Result<super::super::Enum, ::buffa::DecodeError> {
1378        #[allow(unused_imports)]
1379        use ::buffa::alloc::string::ToString as _;
1380        let _ = __buffa_src;
1381        ::core::result::Result::Ok(super::super::Enum {
1382            name: self.name.to_string(),
1383            enumvalue: self
1384                .enumvalue
1385                .iter()
1386                .map(|v| v.to_owned_from_source(__buffa_src))
1387                .collect::<::core::result::Result<_, ::buffa::DecodeError>>()?,
1388            options: self
1389                .options
1390                .iter()
1391                .map(|v| v.to_owned_from_source(__buffa_src))
1392                .collect::<::core::result::Result<_, ::buffa::DecodeError>>()?,
1393            source_context: match self.source_context.as_option() {
1394                Some(v) => {
1395                    ::buffa::MessageField::<
1396                        super::super::SourceContext,
1397                        ::buffa::Inline<super::super::SourceContext>,
1398                    >::some(v.to_owned_from_source(__buffa_src)?)
1399                }
1400                None => ::buffa::MessageField::none(),
1401            },
1402            syntax: self.syntax,
1403            edition: self.edition.to_string(),
1404            __buffa_unknown_fields: self.__buffa_unknown_fields.to_owned()?.into(),
1405            ..::core::default::Default::default()
1406        })
1407    }
1408}
1409impl<'a> ::buffa::ViewEncode<'a> for EnumView<'a> {
1410    #[allow(clippy::needless_borrow, clippy::let_and_return)]
1411    fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 {
1412        #[allow(unused_imports)]
1413        use ::buffa::Enumeration as _;
1414        let mut size = 0u64;
1415        if !self.name.is_empty() {
1416            size += 1u64 + ::buffa::types::string_encoded_len(&self.name) as u64;
1417        }
1418        for v in &self.enumvalue {
1419            let __slot = __cache.reserve();
1420            let inner_size = v.compute_size(__cache);
1421            __cache.set(__slot, inner_size);
1422            size
1423                += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64
1424                    + inner_size as u64;
1425        }
1426        for v in &self.options {
1427            let __slot = __cache.reserve();
1428            let inner_size = v.compute_size(__cache);
1429            __cache.set(__slot, inner_size);
1430            size
1431                += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64
1432                    + inner_size as u64;
1433        }
1434        if self.source_context.is_set() {
1435            let __slot = __cache.reserve();
1436            let inner_size = self.source_context.compute_size(__cache);
1437            __cache.set(__slot, inner_size);
1438            size
1439                += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64
1440                    + inner_size as u64;
1441        }
1442        {
1443            let val = self.syntax.to_i32();
1444            if val != 0 {
1445                size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64;
1446            }
1447        }
1448        if !self.edition.is_empty() {
1449            size += 1u64 + ::buffa::types::string_encoded_len(&self.edition) as u64;
1450        }
1451        size += self.__buffa_unknown_fields.encoded_len() as u64;
1452        ::buffa::saturate_size(size)
1453    }
1454    #[allow(clippy::needless_borrow)]
1455    fn write_to(
1456        &self,
1457        __cache: &mut ::buffa::SizeCache,
1458        buf: &mut impl ::buffa::EncodeSink,
1459    ) {
1460        #[allow(unused_imports)]
1461        use ::buffa::Enumeration as _;
1462        if !self.name.is_empty() {
1463            ::buffa::types::put_string_field(1u32, &self.name, buf);
1464        }
1465        for v in &self.enumvalue {
1466            ::buffa::types::put_len_delimited_header(
1467                2u32,
1468                u64::from(__cache.consume_next()),
1469                buf,
1470            );
1471            v.write_to(__cache, buf);
1472        }
1473        for v in &self.options {
1474            ::buffa::types::put_len_delimited_header(
1475                3u32,
1476                u64::from(__cache.consume_next()),
1477                buf,
1478            );
1479            v.write_to(__cache, buf);
1480        }
1481        if self.source_context.is_set() {
1482            ::buffa::types::put_len_delimited_header(
1483                4u32,
1484                u64::from(__cache.consume_next()),
1485                buf,
1486            );
1487            self.source_context.write_to(__cache, buf);
1488        }
1489        {
1490            let val = self.syntax.to_i32();
1491            if val != 0 {
1492                ::buffa::types::put_int32_field(5u32, val, buf);
1493            }
1494        }
1495        if !self.edition.is_empty() {
1496            ::buffa::types::put_string_field(6u32, &self.edition, buf);
1497        }
1498        self.__buffa_unknown_fields.write_to(buf);
1499    }
1500}
1501impl<'a> ::buffa::MessageName for EnumView<'a> {
1502    const PACKAGE: &'static str = "google.protobuf";
1503    const NAME: &'static str = "Enum";
1504    const FULL_NAME: &'static str = "google.protobuf.Enum";
1505    const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.Enum";
1506}
1507::buffa::impl_default_view_instance!(EnumView);
1508::buffa::impl_view_reborrow!(EnumView);
1509/** Self-contained, `'static` owned view of a `Enum` message.
1510
1511 Wraps [`::buffa::OwnedView`]`<`[`EnumView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required.
1512
1513 Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`EnumView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/
1514#[derive(Clone, Debug)]
1515pub struct EnumOwnedView(::buffa::OwnedView<EnumView<'static>>);
1516impl EnumOwnedView {
1517    /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer.
1518    ///
1519    /// The view borrows directly from the buffer's data; the buffer is
1520    /// retained inside the returned handle.
1521    ///
1522    /// # Errors
1523    ///
1524    /// Returns [`::buffa::DecodeError`] if the buffer contains invalid
1525    /// protobuf data.
1526    pub fn decode(
1527        bytes: ::buffa::bytes::Bytes,
1528    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
1529        ::core::result::Result::Ok(EnumOwnedView(::buffa::OwnedView::decode(bytes)?))
1530    }
1531    /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit,
1532    /// max message size).
1533    ///
1534    /// # Errors
1535    ///
1536    /// Returns [`::buffa::DecodeError`] if the buffer is invalid or
1537    /// exceeds the configured limits.
1538    pub fn decode_with_options(
1539        bytes: ::buffa::bytes::Bytes,
1540        opts: &::buffa::DecodeOptions,
1541    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
1542        ::core::result::Result::Ok(
1543            EnumOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?),
1544        )
1545    }
1546    /// Build from an owned message via an encode → decode round-trip.
1547    ///
1548    /// # Errors
1549    ///
1550    /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the
1551    /// message's encoded size exceeds the 2 GiB protobuf limit, or
1552    /// another [`::buffa::DecodeError`] if the re-encoded bytes are
1553    /// somehow invalid (should not happen for well-formed messages).
1554    pub fn from_owned(
1555        msg: &super::super::Enum,
1556    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
1557        ::core::result::Result::Ok(EnumOwnedView(::buffa::OwnedView::from_owned(msg)?))
1558    }
1559    /// Borrow the full [`EnumView`] with its lifetime tied to `&self`.
1560    #[must_use]
1561    pub fn view(&self) -> &EnumView<'_> {
1562        self.0.reborrow()
1563    }
1564    /// Convert to the owned message type.
1565    ///
1566    /// Infallible: this type's constructors wire-decode their
1567    /// buffer, and a view produced by wire decoding always
1568    /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`],
1569    /// whose contract also governs handles converted from a raw
1570    /// [`::buffa::OwnedView`].
1571    #[must_use]
1572    pub fn to_owned_message(&self) -> super::super::Enum {
1573        self.0.to_owned_message()
1574    }
1575    /// The underlying bytes buffer.
1576    #[must_use]
1577    pub fn bytes(&self) -> &::buffa::bytes::Bytes {
1578        self.0.bytes()
1579    }
1580    /// Consume the handle, returning the underlying bytes buffer.
1581    #[must_use]
1582    pub fn into_bytes(self) -> ::buffa::bytes::Bytes {
1583        self.0.into_bytes()
1584    }
1585    /// Enum type name.
1586    ///
1587    /// Field 1: `name`
1588    #[must_use]
1589    pub fn name(&self) -> &'_ str {
1590        self.0.reborrow().name
1591    }
1592    /// Enum value definitions.
1593    ///
1594    /// Field 2: `enumvalue`
1595    #[must_use]
1596    pub fn enumvalue(
1597        &self,
1598    ) -> &::buffa::RepeatedView<'_, super::super::__buffa::view::EnumValueView<'_>> {
1599        &self.0.reborrow().enumvalue
1600    }
1601    /// Protocol buffer options.
1602    ///
1603    /// Field 3: `options`
1604    #[must_use]
1605    pub fn options(
1606        &self,
1607    ) -> &::buffa::RepeatedView<'_, super::super::__buffa::view::OptionView<'_>> {
1608        &self.0.reborrow().options
1609    }
1610    /// The source context.
1611    ///
1612    /// Field 4: `source_context`
1613    #[must_use]
1614    pub fn source_context(
1615        &self,
1616    ) -> &::buffa::MessageFieldView<super::super::__buffa::view::SourceContextView<'_>> {
1617        &self.0.reborrow().source_context
1618    }
1619    /// The source syntax.
1620    ///
1621    /// Field 5: `syntax`
1622    #[must_use]
1623    pub fn syntax(&self) -> ::buffa::EnumValue<super::super::Syntax> {
1624        self.0.reborrow().syntax
1625    }
1626    /// The source edition string, only valid when syntax is SYNTAX_EDITIONS.
1627    ///
1628    /// Field 6: `edition`
1629    #[must_use]
1630    pub fn edition(&self) -> &'_ str {
1631        self.0.reborrow().edition
1632    }
1633}
1634impl ::core::convert::From<::buffa::OwnedView<EnumView<'static>>> for EnumOwnedView {
1635    fn from(inner: ::buffa::OwnedView<EnumView<'static>>) -> Self {
1636        EnumOwnedView(inner)
1637    }
1638}
1639impl ::core::convert::From<EnumOwnedView> for ::buffa::OwnedView<EnumView<'static>> {
1640    fn from(wrapper: EnumOwnedView) -> Self {
1641        wrapper.0
1642    }
1643}
1644impl ::core::convert::AsRef<::buffa::OwnedView<EnumView<'static>>> for EnumOwnedView {
1645    fn as_ref(&self) -> &::buffa::OwnedView<EnumView<'static>> {
1646        &self.0
1647    }
1648}
1649impl ::buffa::HasMessageView for super::super::Enum {
1650    type View<'a> = EnumView<'a>;
1651    type ViewHandle = EnumOwnedView;
1652}
1653#[cfg(feature = "reflect")]
1654const _: () = {
1655    impl<'a> ::buffa_descriptor::reflect::ReflectMessage for EnumView<'a> {
1656        fn message_descriptor(&self) -> &::buffa_descriptor::MessageDescriptor {
1657            super::super::__buffa::reflect::descriptor_pool()
1658                .message(Self::__buffa_reflect_message_index())
1659        }
1660        fn pool(
1661            &self,
1662        ) -> &::buffa::alloc::sync::Arc<::buffa_descriptor::DescriptorPool> {
1663            super::super::__buffa::reflect::descriptor_pool()
1664        }
1665        fn get(
1666            &self,
1667            field: &::buffa_descriptor::FieldDescriptor,
1668        ) -> ::buffa_descriptor::reflect::ValueRef<'_> {
1669            #[allow(unused_imports)]
1670            use ::buffa::Enumeration as _;
1671            match field.number() {
1672                1u32 => ::buffa_descriptor::reflect::ValueRef::String(self.name),
1673                2u32 => ::buffa_descriptor::reflect::ValueRef::List(&self.enumvalue),
1674                3u32 => ::buffa_descriptor::reflect::ValueRef::List(&self.options),
1675                4u32 => {
1676                    ::buffa_descriptor::reflect::ValueRef::Message(
1677                        ::buffa_descriptor::reflect::ReflectCow::Borrowed(
1678                            &*self.source_context,
1679                        ),
1680                    )
1681                }
1682                5u32 => {
1683                    ::buffa_descriptor::reflect::ValueRef::EnumNumber(
1684                        self.syntax.to_i32(),
1685                    )
1686                }
1687                6u32 => ::buffa_descriptor::reflect::ValueRef::String(self.edition),
1688                _ => {
1689                    ::core::debug_assert!(
1690                        false,
1691                        "field number {} is not a member of this view's reflect get()",
1692                        field.number(),
1693                    );
1694                    ::buffa_descriptor::reflect::ValueRef::Bool(false)
1695                }
1696            }
1697        }
1698        fn has(&self, field: &::buffa_descriptor::FieldDescriptor) -> bool {
1699            match field.number() {
1700                1u32 => !self.name.is_empty(),
1701                2u32 => !::buffa::RepeatedView::is_empty(&self.enumvalue),
1702                3u32 => !::buffa::RepeatedView::is_empty(&self.options),
1703                4u32 => self.source_context.is_set(),
1704                5u32 => self.syntax.to_i32() != 0,
1705                6u32 => !self.edition.is_empty(),
1706                _ => false,
1707            }
1708        }
1709        fn for_each_set(
1710            &self,
1711            f: &mut dyn ::core::ops::FnMut(
1712                &::buffa_descriptor::FieldDescriptor,
1713                ::buffa_descriptor::reflect::ValueRef<'_>,
1714            ),
1715        ) {
1716            let md = ::buffa_descriptor::reflect::ReflectMessage::message_descriptor(
1717                self,
1718            );
1719            for fd in md.fields() {
1720                if ::buffa_descriptor::reflect::ReflectMessage::has(self, fd) {
1721                    f(fd, ::buffa_descriptor::reflect::ReflectMessage::get(self, fd));
1722                }
1723            }
1724        }
1725        fn to_dynamic(&self) -> ::buffa_descriptor::reflect::DynamicMessage {
1726            let bytes = ::buffa::ViewEncode::encode_to_vec(self);
1727            let options = ::buffa::DecodeOptions::new()
1728                .with_element_memory_limit(
1729                    bytes
1730                        .len()
1731                        .saturating_mul(128)
1732                        .max(::buffa::DEFAULT_ELEMENT_MEMORY_LIMIT),
1733                )
1734                .with_unknown_field_limit(
1735                    bytes.len().max(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT),
1736                );
1737            ::buffa_descriptor::reflect::DynamicMessage::decode_with_options(
1738                    ::buffa::alloc::sync::Arc::clone(
1739                        super::super::__buffa::reflect::descriptor_pool(),
1740                    ),
1741                    Self::__buffa_reflect_message_index(),
1742                    &bytes,
1743                    &options,
1744                )
1745                .expect("view re-encodes to bytes decodable against its own descriptor")
1746        }
1747    }
1748    impl<'a> ::buffa_descriptor::reflect::ReflectElement for EnumView<'a> {
1749        fn as_value_ref(&self) -> ::buffa_descriptor::reflect::ValueRef<'_> {
1750            ::buffa_descriptor::reflect::ValueRef::Message(
1751                ::buffa_descriptor::reflect::ReflectCow::Borrowed(self),
1752            )
1753        }
1754    }
1755    impl<'a> EnumView<'a> {
1756        /// Memoized `MessageIndex` for this view's message type, resolved
1757        /// once against the package's embedded descriptor pool. An inherent
1758        /// associated fn (not a free fn) so sibling views in the same module
1759        /// do not collide.
1760        #[doc(hidden)]
1761        fn __buffa_reflect_message_index() -> ::buffa_descriptor::MessageIndex {
1762            static IDX: ::std::sync::OnceLock<::buffa_descriptor::MessageIndex> = ::std::sync::OnceLock::new();
1763            *IDX
1764                .get_or_init(|| {
1765                    super::super::__buffa::reflect::descriptor_pool()
1766                        .message_index(<Self as ::buffa::MessageName>::FULL_NAME)
1767                        .expect(
1768                            "generated view type is registered in the embedded descriptor pool",
1769                        )
1770                })
1771        }
1772    }
1773};
1774/// Enum value definition.
1775///
1776/// New usages of this message as an alternative to EnumValueDescriptorProto are
1777/// strongly discouraged. This message does not reliability preserve all
1778/// information necessary to model the schema and preserve semantics. Instead
1779/// make use of FileDescriptorSet which preserves the necessary information.
1780#[derive(Clone, Debug, Default)]
1781pub struct EnumValueView<'a> {
1782    /// Enum value name.
1783    ///
1784    /// Field 1: `name`
1785    pub name: &'a str,
1786    /// Enum value number.
1787    ///
1788    /// Field 2: `number`
1789    pub number: i32,
1790    /// Protocol buffer options.
1791    ///
1792    /// Field 3: `options`
1793    pub options: ::buffa::RepeatedView<'a, super::super::__buffa::view::OptionView<'a>>,
1794    pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
1795}
1796impl<'a> ::buffa::MessageView<'a> for EnumValueView<'a> {
1797    type Owned = super::super::EnumValue;
1798    fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
1799        let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT);
1800        let __elem = ::core::cell::Cell::new(::buffa::DEFAULT_ELEMENT_MEMORY_LIMIT);
1801        <Self as ::buffa::MessageView>::decode_view_ctx(
1802            buf,
1803            ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit)
1804                .with_element_memory(&__elem),
1805        )
1806    }
1807    fn decode_view_with_ctx(
1808        buf: &'a [u8],
1809        ctx: ::buffa::DecodeContext<'_>,
1810    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
1811        <Self as ::buffa::MessageView>::decode_view_ctx(buf, ctx)
1812    }
1813    #[inline]
1814    fn merge_view_field(
1815        &mut self,
1816        tag: ::buffa::encoding::Tag,
1817        cur: &'a [u8],
1818        before_tag: &'a [u8],
1819        ctx: ::buffa::DecodeContext<'_>,
1820    ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> {
1821        let _ = ctx;
1822        #[allow(unused_variables)]
1823        let view = self;
1824        let mut cur = cur;
1825        match tag.field_number() {
1826            1u32 => {
1827                ::buffa::encoding::check_wire_type(
1828                    tag,
1829                    ::buffa::encoding::WireType::LengthDelimited,
1830                )?;
1831                view.name = ::buffa::types::borrow_str(&mut cur)?;
1832            }
1833            2u32 => {
1834                ::buffa::encoding::check_wire_type(
1835                    tag,
1836                    ::buffa::encoding::WireType::Varint,
1837                )?;
1838                view.number = ::buffa::types::decode_int32(&mut cur)?;
1839            }
1840            3u32 => {
1841                ::buffa::encoding::check_wire_type(
1842                    tag,
1843                    ::buffa::encoding::WireType::LengthDelimited,
1844                )?;
1845                let __sub_ctx = ctx.descend()?;
1846                let sub = ::buffa::types::borrow_bytes(&mut cur)?;
1847                ctx.register_element_memory(
1848                    ::core::mem::size_of::<super::super::__buffa::view::OptionView>(),
1849                )?;
1850                view.options
1851                    .push(
1852                        <super::super::__buffa::view::OptionView as ::buffa::MessageView>::decode_view_ctx(
1853                            sub,
1854                            __sub_ctx,
1855                        )?,
1856                    );
1857            }
1858            _ => {
1859                ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?;
1860                let span_len = before_tag.len() - cur.len();
1861                view.__buffa_unknown_fields.push_record(before_tag, span_len, ctx)?;
1862            }
1863        }
1864        ::core::result::Result::Ok(cur)
1865    }
1866    fn to_owned_message(
1867        &self,
1868    ) -> ::core::result::Result<super::super::EnumValue, ::buffa::DecodeError> {
1869        self.to_owned_from_source(None)
1870    }
1871    #[allow(clippy::useless_conversion, clippy::needless_update)]
1872    fn to_owned_from_source(
1873        &self,
1874        __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>,
1875    ) -> ::core::result::Result<super::super::EnumValue, ::buffa::DecodeError> {
1876        #[allow(unused_imports)]
1877        use ::buffa::alloc::string::ToString as _;
1878        let _ = __buffa_src;
1879        ::core::result::Result::Ok(super::super::EnumValue {
1880            name: self.name.to_string(),
1881            number: self.number,
1882            options: self
1883                .options
1884                .iter()
1885                .map(|v| v.to_owned_from_source(__buffa_src))
1886                .collect::<::core::result::Result<_, ::buffa::DecodeError>>()?,
1887            __buffa_unknown_fields: self.__buffa_unknown_fields.to_owned()?.into(),
1888            ..::core::default::Default::default()
1889        })
1890    }
1891}
1892impl<'a> ::buffa::ViewEncode<'a> for EnumValueView<'a> {
1893    #[allow(clippy::needless_borrow, clippy::let_and_return)]
1894    fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 {
1895        #[allow(unused_imports)]
1896        use ::buffa::Enumeration as _;
1897        let mut size = 0u64;
1898        if !self.name.is_empty() {
1899            size += 1u64 + ::buffa::types::string_encoded_len(&self.name) as u64;
1900        }
1901        if self.number != 0i32 {
1902            size += 1u64 + ::buffa::types::int32_encoded_len(self.number) as u64;
1903        }
1904        for v in &self.options {
1905            let __slot = __cache.reserve();
1906            let inner_size = v.compute_size(__cache);
1907            __cache.set(__slot, inner_size);
1908            size
1909                += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64
1910                    + inner_size as u64;
1911        }
1912        size += self.__buffa_unknown_fields.encoded_len() as u64;
1913        ::buffa::saturate_size(size)
1914    }
1915    #[allow(clippy::needless_borrow)]
1916    fn write_to(
1917        &self,
1918        __cache: &mut ::buffa::SizeCache,
1919        buf: &mut impl ::buffa::EncodeSink,
1920    ) {
1921        #[allow(unused_imports)]
1922        use ::buffa::Enumeration as _;
1923        if !self.name.is_empty() {
1924            ::buffa::types::put_string_field(1u32, &self.name, buf);
1925        }
1926        if self.number != 0i32 {
1927            ::buffa::types::put_int32_field(2u32, self.number, buf);
1928        }
1929        for v in &self.options {
1930            ::buffa::types::put_len_delimited_header(
1931                3u32,
1932                u64::from(__cache.consume_next()),
1933                buf,
1934            );
1935            v.write_to(__cache, buf);
1936        }
1937        self.__buffa_unknown_fields.write_to(buf);
1938    }
1939}
1940impl<'a> ::buffa::MessageName for EnumValueView<'a> {
1941    const PACKAGE: &'static str = "google.protobuf";
1942    const NAME: &'static str = "EnumValue";
1943    const FULL_NAME: &'static str = "google.protobuf.EnumValue";
1944    const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.EnumValue";
1945}
1946::buffa::impl_default_view_instance!(EnumValueView);
1947::buffa::impl_view_reborrow!(EnumValueView);
1948/** Self-contained, `'static` owned view of a `EnumValue` message.
1949
1950 Wraps [`::buffa::OwnedView`]`<`[`EnumValueView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required.
1951
1952 Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`EnumValueView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/
1953#[derive(Clone, Debug)]
1954pub struct EnumValueOwnedView(::buffa::OwnedView<EnumValueView<'static>>);
1955impl EnumValueOwnedView {
1956    /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer.
1957    ///
1958    /// The view borrows directly from the buffer's data; the buffer is
1959    /// retained inside the returned handle.
1960    ///
1961    /// # Errors
1962    ///
1963    /// Returns [`::buffa::DecodeError`] if the buffer contains invalid
1964    /// protobuf data.
1965    pub fn decode(
1966        bytes: ::buffa::bytes::Bytes,
1967    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
1968        ::core::result::Result::Ok(
1969            EnumValueOwnedView(::buffa::OwnedView::decode(bytes)?),
1970        )
1971    }
1972    /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit,
1973    /// max message size).
1974    ///
1975    /// # Errors
1976    ///
1977    /// Returns [`::buffa::DecodeError`] if the buffer is invalid or
1978    /// exceeds the configured limits.
1979    pub fn decode_with_options(
1980        bytes: ::buffa::bytes::Bytes,
1981        opts: &::buffa::DecodeOptions,
1982    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
1983        ::core::result::Result::Ok(
1984            EnumValueOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?),
1985        )
1986    }
1987    /// Build from an owned message via an encode → decode round-trip.
1988    ///
1989    /// # Errors
1990    ///
1991    /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the
1992    /// message's encoded size exceeds the 2 GiB protobuf limit, or
1993    /// another [`::buffa::DecodeError`] if the re-encoded bytes are
1994    /// somehow invalid (should not happen for well-formed messages).
1995    pub fn from_owned(
1996        msg: &super::super::EnumValue,
1997    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
1998        ::core::result::Result::Ok(
1999            EnumValueOwnedView(::buffa::OwnedView::from_owned(msg)?),
2000        )
2001    }
2002    /// Borrow the full [`EnumValueView`] with its lifetime tied to `&self`.
2003    #[must_use]
2004    pub fn view(&self) -> &EnumValueView<'_> {
2005        self.0.reborrow()
2006    }
2007    /// Convert to the owned message type.
2008    ///
2009    /// Infallible: this type's constructors wire-decode their
2010    /// buffer, and a view produced by wire decoding always
2011    /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`],
2012    /// whose contract also governs handles converted from a raw
2013    /// [`::buffa::OwnedView`].
2014    #[must_use]
2015    pub fn to_owned_message(&self) -> super::super::EnumValue {
2016        self.0.to_owned_message()
2017    }
2018    /// The underlying bytes buffer.
2019    #[must_use]
2020    pub fn bytes(&self) -> &::buffa::bytes::Bytes {
2021        self.0.bytes()
2022    }
2023    /// Consume the handle, returning the underlying bytes buffer.
2024    #[must_use]
2025    pub fn into_bytes(self) -> ::buffa::bytes::Bytes {
2026        self.0.into_bytes()
2027    }
2028    /// Enum value name.
2029    ///
2030    /// Field 1: `name`
2031    #[must_use]
2032    pub fn name(&self) -> &'_ str {
2033        self.0.reborrow().name
2034    }
2035    /// Enum value number.
2036    ///
2037    /// Field 2: `number`
2038    #[must_use]
2039    pub fn number(&self) -> i32 {
2040        self.0.reborrow().number
2041    }
2042    /// Protocol buffer options.
2043    ///
2044    /// Field 3: `options`
2045    #[must_use]
2046    pub fn options(
2047        &self,
2048    ) -> &::buffa::RepeatedView<'_, super::super::__buffa::view::OptionView<'_>> {
2049        &self.0.reborrow().options
2050    }
2051}
2052impl ::core::convert::From<::buffa::OwnedView<EnumValueView<'static>>>
2053for EnumValueOwnedView {
2054    fn from(inner: ::buffa::OwnedView<EnumValueView<'static>>) -> Self {
2055        EnumValueOwnedView(inner)
2056    }
2057}
2058impl ::core::convert::From<EnumValueOwnedView>
2059for ::buffa::OwnedView<EnumValueView<'static>> {
2060    fn from(wrapper: EnumValueOwnedView) -> Self {
2061        wrapper.0
2062    }
2063}
2064impl ::core::convert::AsRef<::buffa::OwnedView<EnumValueView<'static>>>
2065for EnumValueOwnedView {
2066    fn as_ref(&self) -> &::buffa::OwnedView<EnumValueView<'static>> {
2067        &self.0
2068    }
2069}
2070impl ::buffa::HasMessageView for super::super::EnumValue {
2071    type View<'a> = EnumValueView<'a>;
2072    type ViewHandle = EnumValueOwnedView;
2073}
2074#[cfg(feature = "reflect")]
2075const _: () = {
2076    impl<'a> ::buffa_descriptor::reflect::ReflectMessage for EnumValueView<'a> {
2077        fn message_descriptor(&self) -> &::buffa_descriptor::MessageDescriptor {
2078            super::super::__buffa::reflect::descriptor_pool()
2079                .message(Self::__buffa_reflect_message_index())
2080        }
2081        fn pool(
2082            &self,
2083        ) -> &::buffa::alloc::sync::Arc<::buffa_descriptor::DescriptorPool> {
2084            super::super::__buffa::reflect::descriptor_pool()
2085        }
2086        fn get(
2087            &self,
2088            field: &::buffa_descriptor::FieldDescriptor,
2089        ) -> ::buffa_descriptor::reflect::ValueRef<'_> {
2090            #[allow(unused_imports)]
2091            use ::buffa::Enumeration as _;
2092            match field.number() {
2093                1u32 => ::buffa_descriptor::reflect::ValueRef::String(self.name),
2094                2u32 => ::buffa_descriptor::reflect::ValueRef::I32(self.number),
2095                3u32 => ::buffa_descriptor::reflect::ValueRef::List(&self.options),
2096                _ => {
2097                    ::core::debug_assert!(
2098                        false,
2099                        "field number {} is not a member of this view's reflect get()",
2100                        field.number(),
2101                    );
2102                    ::buffa_descriptor::reflect::ValueRef::Bool(false)
2103                }
2104            }
2105        }
2106        fn has(&self, field: &::buffa_descriptor::FieldDescriptor) -> bool {
2107            match field.number() {
2108                1u32 => !self.name.is_empty(),
2109                2u32 => self.number != 0,
2110                3u32 => !::buffa::RepeatedView::is_empty(&self.options),
2111                _ => false,
2112            }
2113        }
2114        fn for_each_set(
2115            &self,
2116            f: &mut dyn ::core::ops::FnMut(
2117                &::buffa_descriptor::FieldDescriptor,
2118                ::buffa_descriptor::reflect::ValueRef<'_>,
2119            ),
2120        ) {
2121            let md = ::buffa_descriptor::reflect::ReflectMessage::message_descriptor(
2122                self,
2123            );
2124            for fd in md.fields() {
2125                if ::buffa_descriptor::reflect::ReflectMessage::has(self, fd) {
2126                    f(fd, ::buffa_descriptor::reflect::ReflectMessage::get(self, fd));
2127                }
2128            }
2129        }
2130        fn to_dynamic(&self) -> ::buffa_descriptor::reflect::DynamicMessage {
2131            let bytes = ::buffa::ViewEncode::encode_to_vec(self);
2132            let options = ::buffa::DecodeOptions::new()
2133                .with_element_memory_limit(
2134                    bytes
2135                        .len()
2136                        .saturating_mul(128)
2137                        .max(::buffa::DEFAULT_ELEMENT_MEMORY_LIMIT),
2138                )
2139                .with_unknown_field_limit(
2140                    bytes.len().max(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT),
2141                );
2142            ::buffa_descriptor::reflect::DynamicMessage::decode_with_options(
2143                    ::buffa::alloc::sync::Arc::clone(
2144                        super::super::__buffa::reflect::descriptor_pool(),
2145                    ),
2146                    Self::__buffa_reflect_message_index(),
2147                    &bytes,
2148                    &options,
2149                )
2150                .expect("view re-encodes to bytes decodable against its own descriptor")
2151        }
2152    }
2153    impl<'a> ::buffa_descriptor::reflect::ReflectElement for EnumValueView<'a> {
2154        fn as_value_ref(&self) -> ::buffa_descriptor::reflect::ValueRef<'_> {
2155            ::buffa_descriptor::reflect::ValueRef::Message(
2156                ::buffa_descriptor::reflect::ReflectCow::Borrowed(self),
2157            )
2158        }
2159    }
2160    impl<'a> EnumValueView<'a> {
2161        /// Memoized `MessageIndex` for this view's message type, resolved
2162        /// once against the package's embedded descriptor pool. An inherent
2163        /// associated fn (not a free fn) so sibling views in the same module
2164        /// do not collide.
2165        #[doc(hidden)]
2166        fn __buffa_reflect_message_index() -> ::buffa_descriptor::MessageIndex {
2167            static IDX: ::std::sync::OnceLock<::buffa_descriptor::MessageIndex> = ::std::sync::OnceLock::new();
2168            *IDX
2169                .get_or_init(|| {
2170                    super::super::__buffa::reflect::descriptor_pool()
2171                        .message_index(<Self as ::buffa::MessageName>::FULL_NAME)
2172                        .expect(
2173                            "generated view type is registered in the embedded descriptor pool",
2174                        )
2175                })
2176        }
2177    }
2178};
2179/// A protocol buffer option, which can be attached to a message, field,
2180/// enumeration, etc.
2181///
2182/// New usages of this message as an alternative to FileOptions, MessageOptions,
2183/// FieldOptions, EnumOptions, EnumValueOptions, ServiceOptions, or MethodOptions
2184/// are strongly discouraged.
2185#[derive(Clone, Debug, Default)]
2186pub struct OptionView<'a> {
2187    /// The option's name. For protobuf built-in options (options defined in
2188    /// descriptor.proto), this is the short name. For example, `"map_entry"`.
2189    /// For custom options, it should be the fully-qualified name. For example,
2190    /// `"google.api.http"`.
2191    ///
2192    /// Field 1: `name`
2193    pub name: &'a str,
2194    /// The option's value packed in an Any message. If the value is a primitive,
2195    /// the corresponding wrapper type defined in google/protobuf/wrappers.proto
2196    /// should be used. If the value is an enum, it should be stored as an int32
2197    /// value using the google.protobuf.Int32Value type.
2198    ///
2199    /// Field 2: `value`
2200    pub value: ::buffa::MessageFieldView<super::super::__buffa::view::AnyView<'a>>,
2201    pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
2202}
2203impl<'a> ::buffa::MessageView<'a> for OptionView<'a> {
2204    type Owned = super::super::Option;
2205    fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
2206        let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT);
2207        let __elem = ::core::cell::Cell::new(::buffa::DEFAULT_ELEMENT_MEMORY_LIMIT);
2208        <Self as ::buffa::MessageView>::decode_view_ctx(
2209            buf,
2210            ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit)
2211                .with_element_memory(&__elem),
2212        )
2213    }
2214    fn decode_view_with_ctx(
2215        buf: &'a [u8],
2216        ctx: ::buffa::DecodeContext<'_>,
2217    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
2218        <Self as ::buffa::MessageView>::decode_view_ctx(buf, ctx)
2219    }
2220    #[inline]
2221    fn merge_view_field(
2222        &mut self,
2223        tag: ::buffa::encoding::Tag,
2224        cur: &'a [u8],
2225        before_tag: &'a [u8],
2226        ctx: ::buffa::DecodeContext<'_>,
2227    ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> {
2228        let _ = ctx;
2229        #[allow(unused_variables)]
2230        let view = self;
2231        let mut cur = cur;
2232        match tag.field_number() {
2233            1u32 => {
2234                ::buffa::encoding::check_wire_type(
2235                    tag,
2236                    ::buffa::encoding::WireType::LengthDelimited,
2237                )?;
2238                view.name = ::buffa::types::borrow_str(&mut cur)?;
2239            }
2240            2u32 => {
2241                ::buffa::encoding::check_wire_type(
2242                    tag,
2243                    ::buffa::encoding::WireType::LengthDelimited,
2244                )?;
2245                let __sub_ctx = ctx.descend()?;
2246                let sub = ::buffa::types::borrow_bytes(&mut cur)?;
2247                match view.value.as_mut() {
2248                    Some(existing) => {
2249                        ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)?
2250                    }
2251                    None => {
2252                        view.value = ::buffa::MessageFieldView::set(
2253                            <super::super::__buffa::view::AnyView as ::buffa::MessageView>::decode_view_ctx(
2254                                sub,
2255                                __sub_ctx,
2256                            )?,
2257                        );
2258                    }
2259                }
2260            }
2261            _ => {
2262                ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?;
2263                let span_len = before_tag.len() - cur.len();
2264                view.__buffa_unknown_fields.push_record(before_tag, span_len, ctx)?;
2265            }
2266        }
2267        ::core::result::Result::Ok(cur)
2268    }
2269    fn to_owned_message(
2270        &self,
2271    ) -> ::core::result::Result<super::super::Option, ::buffa::DecodeError> {
2272        self.to_owned_from_source(None)
2273    }
2274    #[allow(clippy::useless_conversion, clippy::needless_update)]
2275    fn to_owned_from_source(
2276        &self,
2277        __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>,
2278    ) -> ::core::result::Result<super::super::Option, ::buffa::DecodeError> {
2279        #[allow(unused_imports)]
2280        use ::buffa::alloc::string::ToString as _;
2281        let _ = __buffa_src;
2282        ::core::result::Result::Ok(super::super::Option {
2283            name: self.name.to_string(),
2284            value: match self.value.as_option() {
2285                Some(v) => {
2286                    ::buffa::MessageField::<
2287                        super::super::Any,
2288                        ::buffa::Inline<super::super::Any>,
2289                    >::some(v.to_owned_from_source(__buffa_src)?)
2290                }
2291                None => ::buffa::MessageField::none(),
2292            },
2293            __buffa_unknown_fields: self.__buffa_unknown_fields.to_owned()?.into(),
2294            ..::core::default::Default::default()
2295        })
2296    }
2297}
2298impl<'a> ::buffa::ViewEncode<'a> for OptionView<'a> {
2299    #[allow(clippy::needless_borrow, clippy::let_and_return)]
2300    fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 {
2301        #[allow(unused_imports)]
2302        use ::buffa::Enumeration as _;
2303        let mut size = 0u64;
2304        if !self.name.is_empty() {
2305            size += 1u64 + ::buffa::types::string_encoded_len(&self.name) as u64;
2306        }
2307        if self.value.is_set() {
2308            let __slot = __cache.reserve();
2309            let inner_size = self.value.compute_size(__cache);
2310            __cache.set(__slot, inner_size);
2311            size
2312                += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64
2313                    + inner_size as u64;
2314        }
2315        size += self.__buffa_unknown_fields.encoded_len() as u64;
2316        ::buffa::saturate_size(size)
2317    }
2318    #[allow(clippy::needless_borrow)]
2319    fn write_to(
2320        &self,
2321        __cache: &mut ::buffa::SizeCache,
2322        buf: &mut impl ::buffa::EncodeSink,
2323    ) {
2324        #[allow(unused_imports)]
2325        use ::buffa::Enumeration as _;
2326        if !self.name.is_empty() {
2327            ::buffa::types::put_string_field(1u32, &self.name, buf);
2328        }
2329        if self.value.is_set() {
2330            ::buffa::types::put_len_delimited_header(
2331                2u32,
2332                u64::from(__cache.consume_next()),
2333                buf,
2334            );
2335            self.value.write_to(__cache, buf);
2336        }
2337        self.__buffa_unknown_fields.write_to(buf);
2338    }
2339}
2340impl<'a> ::buffa::MessageName for OptionView<'a> {
2341    const PACKAGE: &'static str = "google.protobuf";
2342    const NAME: &'static str = "Option";
2343    const FULL_NAME: &'static str = "google.protobuf.Option";
2344    const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.Option";
2345}
2346::buffa::impl_default_view_instance!(OptionView);
2347::buffa::impl_view_reborrow!(OptionView);
2348/** Self-contained, `'static` owned view of a `Option` message.
2349
2350 Wraps [`::buffa::OwnedView`]`<`[`OptionView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required.
2351
2352 Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`OptionView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/
2353#[derive(Clone, Debug)]
2354pub struct OptionOwnedView(::buffa::OwnedView<OptionView<'static>>);
2355impl OptionOwnedView {
2356    /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer.
2357    ///
2358    /// The view borrows directly from the buffer's data; the buffer is
2359    /// retained inside the returned handle.
2360    ///
2361    /// # Errors
2362    ///
2363    /// Returns [`::buffa::DecodeError`] if the buffer contains invalid
2364    /// protobuf data.
2365    pub fn decode(
2366        bytes: ::buffa::bytes::Bytes,
2367    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
2368        ::core::result::Result::Ok(OptionOwnedView(::buffa::OwnedView::decode(bytes)?))
2369    }
2370    /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit,
2371    /// max message size).
2372    ///
2373    /// # Errors
2374    ///
2375    /// Returns [`::buffa::DecodeError`] if the buffer is invalid or
2376    /// exceeds the configured limits.
2377    pub fn decode_with_options(
2378        bytes: ::buffa::bytes::Bytes,
2379        opts: &::buffa::DecodeOptions,
2380    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
2381        ::core::result::Result::Ok(
2382            OptionOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?),
2383        )
2384    }
2385    /// Build from an owned message via an encode → decode round-trip.
2386    ///
2387    /// # Errors
2388    ///
2389    /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the
2390    /// message's encoded size exceeds the 2 GiB protobuf limit, or
2391    /// another [`::buffa::DecodeError`] if the re-encoded bytes are
2392    /// somehow invalid (should not happen for well-formed messages).
2393    pub fn from_owned(
2394        msg: &super::super::Option,
2395    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
2396        ::core::result::Result::Ok(OptionOwnedView(::buffa::OwnedView::from_owned(msg)?))
2397    }
2398    /// Borrow the full [`OptionView`] with its lifetime tied to `&self`.
2399    #[must_use]
2400    pub fn view(&self) -> &OptionView<'_> {
2401        self.0.reborrow()
2402    }
2403    /// Convert to the owned message type.
2404    ///
2405    /// Infallible: this type's constructors wire-decode their
2406    /// buffer, and a view produced by wire decoding always
2407    /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`],
2408    /// whose contract also governs handles converted from a raw
2409    /// [`::buffa::OwnedView`].
2410    #[must_use]
2411    pub fn to_owned_message(&self) -> super::super::Option {
2412        self.0.to_owned_message()
2413    }
2414    /// The underlying bytes buffer.
2415    #[must_use]
2416    pub fn bytes(&self) -> &::buffa::bytes::Bytes {
2417        self.0.bytes()
2418    }
2419    /// Consume the handle, returning the underlying bytes buffer.
2420    #[must_use]
2421    pub fn into_bytes(self) -> ::buffa::bytes::Bytes {
2422        self.0.into_bytes()
2423    }
2424    /// The option's name. For protobuf built-in options (options defined in
2425    /// descriptor.proto), this is the short name. For example, `"map_entry"`.
2426    /// For custom options, it should be the fully-qualified name. For example,
2427    /// `"google.api.http"`.
2428    ///
2429    /// Field 1: `name`
2430    #[must_use]
2431    pub fn name(&self) -> &'_ str {
2432        self.0.reborrow().name
2433    }
2434    /// The option's value packed in an Any message. If the value is a primitive,
2435    /// the corresponding wrapper type defined in google/protobuf/wrappers.proto
2436    /// should be used. If the value is an enum, it should be stored as an int32
2437    /// value using the google.protobuf.Int32Value type.
2438    ///
2439    /// Field 2: `value`
2440    #[must_use]
2441    pub fn value(
2442        &self,
2443    ) -> &::buffa::MessageFieldView<super::super::__buffa::view::AnyView<'_>> {
2444        &self.0.reborrow().value
2445    }
2446}
2447impl ::core::convert::From<::buffa::OwnedView<OptionView<'static>>> for OptionOwnedView {
2448    fn from(inner: ::buffa::OwnedView<OptionView<'static>>) -> Self {
2449        OptionOwnedView(inner)
2450    }
2451}
2452impl ::core::convert::From<OptionOwnedView> for ::buffa::OwnedView<OptionView<'static>> {
2453    fn from(wrapper: OptionOwnedView) -> Self {
2454        wrapper.0
2455    }
2456}
2457impl ::core::convert::AsRef<::buffa::OwnedView<OptionView<'static>>>
2458for OptionOwnedView {
2459    fn as_ref(&self) -> &::buffa::OwnedView<OptionView<'static>> {
2460        &self.0
2461    }
2462}
2463impl ::buffa::HasMessageView for super::super::Option {
2464    type View<'a> = OptionView<'a>;
2465    type ViewHandle = OptionOwnedView;
2466}
2467#[cfg(feature = "reflect")]
2468const _: () = {
2469    impl<'a> ::buffa_descriptor::reflect::ReflectMessage for OptionView<'a> {
2470        fn message_descriptor(&self) -> &::buffa_descriptor::MessageDescriptor {
2471            super::super::__buffa::reflect::descriptor_pool()
2472                .message(Self::__buffa_reflect_message_index())
2473        }
2474        fn pool(
2475            &self,
2476        ) -> &::buffa::alloc::sync::Arc<::buffa_descriptor::DescriptorPool> {
2477            super::super::__buffa::reflect::descriptor_pool()
2478        }
2479        fn get(
2480            &self,
2481            field: &::buffa_descriptor::FieldDescriptor,
2482        ) -> ::buffa_descriptor::reflect::ValueRef<'_> {
2483            #[allow(unused_imports)]
2484            use ::buffa::Enumeration as _;
2485            match field.number() {
2486                1u32 => ::buffa_descriptor::reflect::ValueRef::String(self.name),
2487                2u32 => {
2488                    ::buffa_descriptor::reflect::ValueRef::Message(
2489                        ::buffa_descriptor::reflect::ReflectCow::Borrowed(&*self.value),
2490                    )
2491                }
2492                _ => {
2493                    ::core::debug_assert!(
2494                        false,
2495                        "field number {} is not a member of this view's reflect get()",
2496                        field.number(),
2497                    );
2498                    ::buffa_descriptor::reflect::ValueRef::Bool(false)
2499                }
2500            }
2501        }
2502        fn has(&self, field: &::buffa_descriptor::FieldDescriptor) -> bool {
2503            match field.number() {
2504                1u32 => !self.name.is_empty(),
2505                2u32 => self.value.is_set(),
2506                _ => false,
2507            }
2508        }
2509        fn for_each_set(
2510            &self,
2511            f: &mut dyn ::core::ops::FnMut(
2512                &::buffa_descriptor::FieldDescriptor,
2513                ::buffa_descriptor::reflect::ValueRef<'_>,
2514            ),
2515        ) {
2516            let md = ::buffa_descriptor::reflect::ReflectMessage::message_descriptor(
2517                self,
2518            );
2519            for fd in md.fields() {
2520                if ::buffa_descriptor::reflect::ReflectMessage::has(self, fd) {
2521                    f(fd, ::buffa_descriptor::reflect::ReflectMessage::get(self, fd));
2522                }
2523            }
2524        }
2525        fn to_dynamic(&self) -> ::buffa_descriptor::reflect::DynamicMessage {
2526            let bytes = ::buffa::ViewEncode::encode_to_vec(self);
2527            let options = ::buffa::DecodeOptions::new()
2528                .with_element_memory_limit(
2529                    bytes
2530                        .len()
2531                        .saturating_mul(128)
2532                        .max(::buffa::DEFAULT_ELEMENT_MEMORY_LIMIT),
2533                )
2534                .with_unknown_field_limit(
2535                    bytes.len().max(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT),
2536                );
2537            ::buffa_descriptor::reflect::DynamicMessage::decode_with_options(
2538                    ::buffa::alloc::sync::Arc::clone(
2539                        super::super::__buffa::reflect::descriptor_pool(),
2540                    ),
2541                    Self::__buffa_reflect_message_index(),
2542                    &bytes,
2543                    &options,
2544                )
2545                .expect("view re-encodes to bytes decodable against its own descriptor")
2546        }
2547    }
2548    impl<'a> ::buffa_descriptor::reflect::ReflectElement for OptionView<'a> {
2549        fn as_value_ref(&self) -> ::buffa_descriptor::reflect::ValueRef<'_> {
2550            ::buffa_descriptor::reflect::ValueRef::Message(
2551                ::buffa_descriptor::reflect::ReflectCow::Borrowed(self),
2552            )
2553        }
2554    }
2555    impl<'a> OptionView<'a> {
2556        /// Memoized `MessageIndex` for this view's message type, resolved
2557        /// once against the package's embedded descriptor pool. An inherent
2558        /// associated fn (not a free fn) so sibling views in the same module
2559        /// do not collide.
2560        #[doc(hidden)]
2561        fn __buffa_reflect_message_index() -> ::buffa_descriptor::MessageIndex {
2562            static IDX: ::std::sync::OnceLock<::buffa_descriptor::MessageIndex> = ::std::sync::OnceLock::new();
2563            *IDX
2564                .get_or_init(|| {
2565                    super::super::__buffa::reflect::descriptor_pool()
2566                        .message_index(<Self as ::buffa::MessageName>::FULL_NAME)
2567                        .expect(
2568                            "generated view type is registered in the embedded descriptor pool",
2569                        )
2570                })
2571        }
2572    }
2573};