Skip to main content

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

1// @generated by buffa-codegen. DO NOT EDIT.
2// source: google/protobuf/api.proto
3
4/// Api is a light-weight descriptor for an API Interface.
5///
6/// Interfaces are also described as "protocol buffer services" in some contexts,
7/// such as by the "service" keyword in a .proto file, but they are different
8/// from API Services, which represent a concrete implementation of an interface
9/// as opposed to simply a description of methods and bindings. They are also
10/// sometimes simply referred to as "APIs" in other contexts, such as the name of
11/// this message itself. See <https://cloud.google.com/apis/design/glossary> for
12/// detailed terminology.
13///
14/// New usages of this message as an alternative to ServiceDescriptorProto are
15/// strongly discouraged. This message does not reliability preserve all
16/// information necessary to model the schema and preserve semantics. Instead
17/// make use of FileDescriptorSet which preserves the necessary information.
18#[derive(Clone, Debug, Default)]
19pub struct ApiView<'a> {
20    /// The fully qualified name of this interface, including package name
21    /// followed by the interface's simple name.
22    ///
23    /// Field 1: `name`
24    pub name: &'a str,
25    /// The methods of this interface, in unspecified order.
26    ///
27    /// Field 2: `methods`
28    pub methods: ::buffa::RepeatedView<'a, super::super::__buffa::view::MethodView<'a>>,
29    /// Any metadata attached to the interface.
30    ///
31    /// Field 3: `options`
32    pub options: ::buffa::RepeatedView<'a, super::super::__buffa::view::OptionView<'a>>,
33    /// A version string for this interface. If specified, must have the form
34    /// `major-version.minor-version`, as in `1.10`. If the minor version is
35    /// omitted, it defaults to zero. If the entire version field is empty, the
36    /// major version is derived from the package name, as outlined below. If the
37    /// field is not empty, the version in the package name will be verified to be
38    /// consistent with what is provided here.
39    ///
40    /// The versioning schema uses \[semantic
41    /// versioning\](<http://semver.org>) where the major version number
42    /// indicates a breaking change and the minor version an additive,
43    /// non-breaking change. Both version numbers are signals to users
44    /// what to expect from different versions, and should be carefully
45    /// chosen based on the product plan.
46    ///
47    /// The major version is also reflected in the package name of the
48    /// interface, which must end in `v<major-version>`, as in
49    /// `google.feature.v1`. For major versions 0 and 1, the suffix can
50    /// be omitted. Zero major versions must only be used for
51    /// experimental, non-GA interfaces.
52    ///
53    /// Field 4: `version`
54    pub version: &'a str,
55    /// Source context for the protocol buffer service represented by this
56    /// message.
57    ///
58    /// Field 5: `source_context`
59    pub source_context: ::buffa::MessageFieldView<
60        super::super::__buffa::view::SourceContextView<'a>,
61    >,
62    /// Included interfaces. See [Mixin].
63    ///
64    /// Field 6: `mixins`
65    pub mixins: ::buffa::RepeatedView<'a, super::super::__buffa::view::MixinView<'a>>,
66    /// The source syntax of the service.
67    ///
68    /// Field 7: `syntax`
69    pub syntax: ::buffa::EnumValue<super::super::Syntax>,
70    /// The source edition string, only valid when syntax is SYNTAX_EDITIONS.
71    ///
72    /// Field 8: `edition`
73    pub edition: &'a str,
74    pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
75}
76impl<'a> ::buffa::MessageView<'a> for ApiView<'a> {
77    type Owned = super::super::Api;
78    fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
79        let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT);
80        let __elem = ::core::cell::Cell::new(::buffa::DEFAULT_ELEMENT_MEMORY_LIMIT);
81        <Self as ::buffa::MessageView>::decode_view_ctx(
82            buf,
83            ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit)
84                .with_element_memory(&__elem),
85        )
86    }
87    fn decode_view_with_ctx(
88        buf: &'a [u8],
89        ctx: ::buffa::DecodeContext<'_>,
90    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
91        <Self as ::buffa::MessageView>::decode_view_ctx(buf, ctx)
92    }
93    #[inline]
94    fn merge_view_field(
95        &mut self,
96        tag: ::buffa::encoding::Tag,
97        cur: &'a [u8],
98        before_tag: &'a [u8],
99        ctx: ::buffa::DecodeContext<'_>,
100    ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> {
101        let _ = ctx;
102        #[allow(unused_variables)]
103        let view = self;
104        let mut cur = cur;
105        match tag.field_number() {
106            1u32 => {
107                ::buffa::encoding::check_wire_type(
108                    tag,
109                    ::buffa::encoding::WireType::LengthDelimited,
110                )?;
111                view.name = ::buffa::types::borrow_str(&mut cur)?;
112            }
113            4u32 => {
114                ::buffa::encoding::check_wire_type(
115                    tag,
116                    ::buffa::encoding::WireType::LengthDelimited,
117                )?;
118                view.version = ::buffa::types::borrow_str(&mut cur)?;
119            }
120            5u32 => {
121                ::buffa::encoding::check_wire_type(
122                    tag,
123                    ::buffa::encoding::WireType::LengthDelimited,
124                )?;
125                let __sub_ctx = ctx.descend()?;
126                let sub = ::buffa::types::borrow_bytes(&mut cur)?;
127                match view.source_context.as_mut() {
128                    Some(existing) => {
129                        ::buffa::MessageView::merge_into_view(existing, sub, __sub_ctx)?
130                    }
131                    None => {
132                        view.source_context = ::buffa::MessageFieldView::set(
133                            <super::super::__buffa::view::SourceContextView as ::buffa::MessageView>::decode_view_ctx(
134                                sub,
135                                __sub_ctx,
136                            )?,
137                        );
138                    }
139                }
140            }
141            7u32 => {
142                ::buffa::encoding::check_wire_type(
143                    tag,
144                    ::buffa::encoding::WireType::Varint,
145                )?;
146                view.syntax = ::buffa::EnumValue::from(
147                    ::buffa::types::decode_int32(&mut cur)?,
148                );
149            }
150            8u32 => {
151                ::buffa::encoding::check_wire_type(
152                    tag,
153                    ::buffa::encoding::WireType::LengthDelimited,
154                )?;
155                view.edition = ::buffa::types::borrow_str(&mut cur)?;
156            }
157            2u32 => {
158                ::buffa::encoding::check_wire_type(
159                    tag,
160                    ::buffa::encoding::WireType::LengthDelimited,
161                )?;
162                let __sub_ctx = ctx.descend()?;
163                let sub = ::buffa::types::borrow_bytes(&mut cur)?;
164                ctx.register_element_memory(
165                    ::core::mem::size_of::<super::super::__buffa::view::MethodView>(),
166                )?;
167                view.methods
168                    .push(
169                        <super::super::__buffa::view::MethodView as ::buffa::MessageView>::decode_view_ctx(
170                            sub,
171                            __sub_ctx,
172                        )?,
173                    );
174            }
175            3u32 => {
176                ::buffa::encoding::check_wire_type(
177                    tag,
178                    ::buffa::encoding::WireType::LengthDelimited,
179                )?;
180                let __sub_ctx = ctx.descend()?;
181                let sub = ::buffa::types::borrow_bytes(&mut cur)?;
182                ctx.register_element_memory(
183                    ::core::mem::size_of::<super::super::__buffa::view::OptionView>(),
184                )?;
185                view.options
186                    .push(
187                        <super::super::__buffa::view::OptionView as ::buffa::MessageView>::decode_view_ctx(
188                            sub,
189                            __sub_ctx,
190                        )?,
191                    );
192            }
193            6u32 => {
194                ::buffa::encoding::check_wire_type(
195                    tag,
196                    ::buffa::encoding::WireType::LengthDelimited,
197                )?;
198                let __sub_ctx = ctx.descend()?;
199                let sub = ::buffa::types::borrow_bytes(&mut cur)?;
200                ctx.register_element_memory(
201                    ::core::mem::size_of::<super::super::__buffa::view::MixinView>(),
202                )?;
203                view.mixins
204                    .push(
205                        <super::super::__buffa::view::MixinView as ::buffa::MessageView>::decode_view_ctx(
206                            sub,
207                            __sub_ctx,
208                        )?,
209                    );
210            }
211            _ => {
212                ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?;
213                let span_len = before_tag.len() - cur.len();
214                view.__buffa_unknown_fields.push_record(before_tag, span_len, ctx)?;
215            }
216        }
217        ::core::result::Result::Ok(cur)
218    }
219    fn to_owned_message(
220        &self,
221    ) -> ::core::result::Result<super::super::Api, ::buffa::DecodeError> {
222        self.to_owned_from_source(None)
223    }
224    #[allow(clippy::useless_conversion, clippy::needless_update)]
225    fn to_owned_from_source(
226        &self,
227        __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>,
228    ) -> ::core::result::Result<super::super::Api, ::buffa::DecodeError> {
229        #[allow(unused_imports)]
230        use ::buffa::alloc::string::ToString as _;
231        let _ = __buffa_src;
232        ::core::result::Result::Ok(super::super::Api {
233            name: self.name.to_string(),
234            methods: self
235                .methods
236                .iter()
237                .map(|v| v.to_owned_from_source(__buffa_src))
238                .collect::<::core::result::Result<_, ::buffa::DecodeError>>()?,
239            options: self
240                .options
241                .iter()
242                .map(|v| v.to_owned_from_source(__buffa_src))
243                .collect::<::core::result::Result<_, ::buffa::DecodeError>>()?,
244            version: self.version.to_string(),
245            source_context: match self.source_context.as_option() {
246                Some(v) => {
247                    ::buffa::MessageField::<
248                        super::super::SourceContext,
249                        ::buffa::Inline<super::super::SourceContext>,
250                    >::some(v.to_owned_from_source(__buffa_src)?)
251                }
252                None => ::buffa::MessageField::none(),
253            },
254            mixins: self
255                .mixins
256                .iter()
257                .map(|v| v.to_owned_from_source(__buffa_src))
258                .collect::<::core::result::Result<_, ::buffa::DecodeError>>()?,
259            syntax: self.syntax,
260            edition: self.edition.to_string(),
261            __buffa_unknown_fields: self.__buffa_unknown_fields.to_owned()?.into(),
262            ..::core::default::Default::default()
263        })
264    }
265}
266impl<'a> ::buffa::ViewEncode<'a> for ApiView<'a> {
267    #[allow(clippy::needless_borrow, clippy::let_and_return)]
268    fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 {
269        #[allow(unused_imports)]
270        use ::buffa::Enumeration as _;
271        let mut size = 0u64;
272        if !self.name.is_empty() {
273            size += 1u64 + ::buffa::types::string_encoded_len(&self.name) as u64;
274        }
275        for v in &self.methods {
276            let __slot = __cache.reserve();
277            let inner_size = v.compute_size(__cache);
278            __cache.set(__slot, inner_size);
279            size
280                += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64
281                    + inner_size as u64;
282        }
283        for v in &self.options {
284            let __slot = __cache.reserve();
285            let inner_size = v.compute_size(__cache);
286            __cache.set(__slot, inner_size);
287            size
288                += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64
289                    + inner_size as u64;
290        }
291        if !self.version.is_empty() {
292            size += 1u64 + ::buffa::types::string_encoded_len(&self.version) as u64;
293        }
294        if self.source_context.is_set() {
295            let __slot = __cache.reserve();
296            let inner_size = self.source_context.compute_size(__cache);
297            __cache.set(__slot, inner_size);
298            size
299                += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64
300                    + inner_size as u64;
301        }
302        for v in &self.mixins {
303            let __slot = __cache.reserve();
304            let inner_size = v.compute_size(__cache);
305            __cache.set(__slot, inner_size);
306            size
307                += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64
308                    + inner_size as u64;
309        }
310        {
311            let val = self.syntax.to_i32();
312            if val != 0 {
313                size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64;
314            }
315        }
316        if !self.edition.is_empty() {
317            size += 1u64 + ::buffa::types::string_encoded_len(&self.edition) as u64;
318        }
319        size += self.__buffa_unknown_fields.encoded_len() as u64;
320        ::buffa::saturate_size(size)
321    }
322    #[allow(clippy::needless_borrow)]
323    fn write_to(
324        &self,
325        __cache: &mut ::buffa::SizeCache,
326        buf: &mut impl ::buffa::EncodeSink,
327    ) {
328        #[allow(unused_imports)]
329        use ::buffa::Enumeration as _;
330        if !self.name.is_empty() {
331            ::buffa::types::put_string_field(1u32, &self.name, buf);
332        }
333        for v in &self.methods {
334            ::buffa::types::put_len_delimited_header(
335                2u32,
336                u64::from(__cache.consume_next()),
337                buf,
338            );
339            v.write_to(__cache, buf);
340        }
341        for v in &self.options {
342            ::buffa::types::put_len_delimited_header(
343                3u32,
344                u64::from(__cache.consume_next()),
345                buf,
346            );
347            v.write_to(__cache, buf);
348        }
349        if !self.version.is_empty() {
350            ::buffa::types::put_string_field(4u32, &self.version, buf);
351        }
352        if self.source_context.is_set() {
353            ::buffa::types::put_len_delimited_header(
354                5u32,
355                u64::from(__cache.consume_next()),
356                buf,
357            );
358            self.source_context.write_to(__cache, buf);
359        }
360        for v in &self.mixins {
361            ::buffa::types::put_len_delimited_header(
362                6u32,
363                u64::from(__cache.consume_next()),
364                buf,
365            );
366            v.write_to(__cache, buf);
367        }
368        {
369            let val = self.syntax.to_i32();
370            if val != 0 {
371                ::buffa::types::put_int32_field(7u32, val, buf);
372            }
373        }
374        if !self.edition.is_empty() {
375            ::buffa::types::put_string_field(8u32, &self.edition, buf);
376        }
377        self.__buffa_unknown_fields.write_to(buf);
378    }
379}
380impl<'a> ::buffa::MessageName for ApiView<'a> {
381    const PACKAGE: &'static str = "google.protobuf";
382    const NAME: &'static str = "Api";
383    const FULL_NAME: &'static str = "google.protobuf.Api";
384    const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.Api";
385}
386::buffa::impl_default_view_instance!(ApiView);
387::buffa::impl_view_reborrow!(ApiView);
388/** Self-contained, `'static` owned view of a `Api` message.
389
390 Wraps [`::buffa::OwnedView`]`<`[`ApiView`]`<'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.
391
392 Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`ApiView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/
393#[derive(Clone, Debug)]
394pub struct ApiOwnedView(::buffa::OwnedView<ApiView<'static>>);
395impl ApiOwnedView {
396    /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer.
397    ///
398    /// The view borrows directly from the buffer's data; the buffer is
399    /// retained inside the returned handle.
400    ///
401    /// # Errors
402    ///
403    /// Returns [`::buffa::DecodeError`] if the buffer contains invalid
404    /// protobuf data.
405    pub fn decode(
406        bytes: ::buffa::bytes::Bytes,
407    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
408        ::core::result::Result::Ok(ApiOwnedView(::buffa::OwnedView::decode(bytes)?))
409    }
410    /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit,
411    /// max message size).
412    ///
413    /// # Errors
414    ///
415    /// Returns [`::buffa::DecodeError`] if the buffer is invalid or
416    /// exceeds the configured limits.
417    pub fn decode_with_options(
418        bytes: ::buffa::bytes::Bytes,
419        opts: &::buffa::DecodeOptions,
420    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
421        ::core::result::Result::Ok(
422            ApiOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?),
423        )
424    }
425    /// Build from an owned message via an encode → decode round-trip.
426    ///
427    /// # Errors
428    ///
429    /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the
430    /// message's encoded size exceeds the 2 GiB protobuf limit, or
431    /// another [`::buffa::DecodeError`] if the re-encoded bytes are
432    /// somehow invalid (should not happen for well-formed messages).
433    pub fn from_owned(
434        msg: &super::super::Api,
435    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
436        ::core::result::Result::Ok(ApiOwnedView(::buffa::OwnedView::from_owned(msg)?))
437    }
438    /// Borrow the full [`ApiView`] with its lifetime tied to `&self`.
439    #[must_use]
440    pub fn view(&self) -> &ApiView<'_> {
441        self.0.reborrow()
442    }
443    /// Convert to the owned message type.
444    ///
445    /// Infallible: this type's constructors wire-decode their
446    /// buffer, and a view produced by wire decoding always
447    /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`],
448    /// whose contract also governs handles converted from a raw
449    /// [`::buffa::OwnedView`].
450    #[must_use]
451    pub fn to_owned_message(&self) -> super::super::Api {
452        self.0.to_owned_message()
453    }
454    /// The underlying bytes buffer.
455    #[must_use]
456    pub fn bytes(&self) -> &::buffa::bytes::Bytes {
457        self.0.bytes()
458    }
459    /// Consume the handle, returning the underlying bytes buffer.
460    #[must_use]
461    pub fn into_bytes(self) -> ::buffa::bytes::Bytes {
462        self.0.into_bytes()
463    }
464    /// The fully qualified name of this interface, including package name
465    /// followed by the interface's simple name.
466    ///
467    /// Field 1: `name`
468    #[must_use]
469    pub fn name(&self) -> &'_ str {
470        self.0.reborrow().name
471    }
472    /// The methods of this interface, in unspecified order.
473    ///
474    /// Field 2: `methods`
475    #[must_use]
476    pub fn methods(
477        &self,
478    ) -> &::buffa::RepeatedView<'_, super::super::__buffa::view::MethodView<'_>> {
479        &self.0.reborrow().methods
480    }
481    /// Any metadata attached to the interface.
482    ///
483    /// Field 3: `options`
484    #[must_use]
485    pub fn options(
486        &self,
487    ) -> &::buffa::RepeatedView<'_, super::super::__buffa::view::OptionView<'_>> {
488        &self.0.reborrow().options
489    }
490    /// A version string for this interface. If specified, must have the form
491    /// `major-version.minor-version`, as in `1.10`. If the minor version is
492    /// omitted, it defaults to zero. If the entire version field is empty, the
493    /// major version is derived from the package name, as outlined below. If the
494    /// field is not empty, the version in the package name will be verified to be
495    /// consistent with what is provided here.
496    ///
497    /// The versioning schema uses \[semantic
498    /// versioning\](<http://semver.org>) where the major version number
499    /// indicates a breaking change and the minor version an additive,
500    /// non-breaking change. Both version numbers are signals to users
501    /// what to expect from different versions, and should be carefully
502    /// chosen based on the product plan.
503    ///
504    /// The major version is also reflected in the package name of the
505    /// interface, which must end in `v<major-version>`, as in
506    /// `google.feature.v1`. For major versions 0 and 1, the suffix can
507    /// be omitted. Zero major versions must only be used for
508    /// experimental, non-GA interfaces.
509    ///
510    /// Field 4: `version`
511    #[must_use]
512    pub fn version(&self) -> &'_ str {
513        self.0.reborrow().version
514    }
515    /// Source context for the protocol buffer service represented by this
516    /// message.
517    ///
518    /// Field 5: `source_context`
519    #[must_use]
520    pub fn source_context(
521        &self,
522    ) -> &::buffa::MessageFieldView<super::super::__buffa::view::SourceContextView<'_>> {
523        &self.0.reborrow().source_context
524    }
525    /// Included interfaces. See [Mixin].
526    ///
527    /// Field 6: `mixins`
528    #[must_use]
529    pub fn mixins(
530        &self,
531    ) -> &::buffa::RepeatedView<'_, super::super::__buffa::view::MixinView<'_>> {
532        &self.0.reborrow().mixins
533    }
534    /// The source syntax of the service.
535    ///
536    /// Field 7: `syntax`
537    #[must_use]
538    pub fn syntax(&self) -> ::buffa::EnumValue<super::super::Syntax> {
539        self.0.reborrow().syntax
540    }
541    /// The source edition string, only valid when syntax is SYNTAX_EDITIONS.
542    ///
543    /// Field 8: `edition`
544    #[must_use]
545    pub fn edition(&self) -> &'_ str {
546        self.0.reborrow().edition
547    }
548}
549impl ::core::convert::From<::buffa::OwnedView<ApiView<'static>>> for ApiOwnedView {
550    fn from(inner: ::buffa::OwnedView<ApiView<'static>>) -> Self {
551        ApiOwnedView(inner)
552    }
553}
554impl ::core::convert::From<ApiOwnedView> for ::buffa::OwnedView<ApiView<'static>> {
555    fn from(wrapper: ApiOwnedView) -> Self {
556        wrapper.0
557    }
558}
559impl ::core::convert::AsRef<::buffa::OwnedView<ApiView<'static>>> for ApiOwnedView {
560    fn as_ref(&self) -> &::buffa::OwnedView<ApiView<'static>> {
561        &self.0
562    }
563}
564impl ::buffa::HasMessageView for super::super::Api {
565    type View<'a> = ApiView<'a>;
566    type ViewHandle = ApiOwnedView;
567}
568#[cfg(feature = "reflect")]
569const _: () = {
570    impl<'a> ::buffa_descriptor::reflect::ReflectMessage for ApiView<'a> {
571        fn message_descriptor(&self) -> &::buffa_descriptor::MessageDescriptor {
572            super::super::__buffa::reflect::descriptor_pool()
573                .message(Self::__buffa_reflect_message_index())
574        }
575        fn pool(
576            &self,
577        ) -> &::buffa::alloc::sync::Arc<::buffa_descriptor::DescriptorPool> {
578            super::super::__buffa::reflect::descriptor_pool()
579        }
580        fn get(
581            &self,
582            field: &::buffa_descriptor::FieldDescriptor,
583        ) -> ::buffa_descriptor::reflect::ValueRef<'_> {
584            #[allow(unused_imports)]
585            use ::buffa::Enumeration as _;
586            match field.number() {
587                1u32 => ::buffa_descriptor::reflect::ValueRef::String(self.name),
588                2u32 => ::buffa_descriptor::reflect::ValueRef::List(&self.methods),
589                3u32 => ::buffa_descriptor::reflect::ValueRef::List(&self.options),
590                4u32 => ::buffa_descriptor::reflect::ValueRef::String(self.version),
591                5u32 => {
592                    ::buffa_descriptor::reflect::ValueRef::Message(
593                        ::buffa_descriptor::reflect::ReflectCow::Borrowed(
594                            &*self.source_context,
595                        ),
596                    )
597                }
598                6u32 => ::buffa_descriptor::reflect::ValueRef::List(&self.mixins),
599                7u32 => {
600                    ::buffa_descriptor::reflect::ValueRef::EnumNumber(
601                        self.syntax.to_i32(),
602                    )
603                }
604                8u32 => ::buffa_descriptor::reflect::ValueRef::String(self.edition),
605                _ => {
606                    ::core::debug_assert!(
607                        false,
608                        "field number {} is not a member of this view's reflect get()",
609                        field.number(),
610                    );
611                    ::buffa_descriptor::reflect::ValueRef::Bool(false)
612                }
613            }
614        }
615        fn has(&self, field: &::buffa_descriptor::FieldDescriptor) -> bool {
616            match field.number() {
617                1u32 => !self.name.is_empty(),
618                2u32 => !::buffa::RepeatedView::is_empty(&self.methods),
619                3u32 => !::buffa::RepeatedView::is_empty(&self.options),
620                4u32 => !self.version.is_empty(),
621                5u32 => self.source_context.is_set(),
622                6u32 => !::buffa::RepeatedView::is_empty(&self.mixins),
623                7u32 => self.syntax.to_i32() != 0,
624                8u32 => !self.edition.is_empty(),
625                _ => false,
626            }
627        }
628        fn for_each_set(
629            &self,
630            f: &mut dyn ::core::ops::FnMut(
631                &::buffa_descriptor::FieldDescriptor,
632                ::buffa_descriptor::reflect::ValueRef<'_>,
633            ),
634        ) {
635            let md = ::buffa_descriptor::reflect::ReflectMessage::message_descriptor(
636                self,
637            );
638            for fd in md.fields() {
639                if ::buffa_descriptor::reflect::ReflectMessage::has(self, fd) {
640                    f(fd, ::buffa_descriptor::reflect::ReflectMessage::get(self, fd));
641                }
642            }
643        }
644        fn to_dynamic(&self) -> ::buffa_descriptor::reflect::DynamicMessage {
645            let bytes = ::buffa::ViewEncode::encode_to_vec(self);
646            let options = ::buffa::DecodeOptions::new()
647                .with_element_memory_limit(
648                    bytes
649                        .len()
650                        .saturating_mul(128)
651                        .max(::buffa::DEFAULT_ELEMENT_MEMORY_LIMIT),
652                )
653                .with_unknown_field_limit(
654                    bytes.len().max(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT),
655                );
656            ::buffa_descriptor::reflect::DynamicMessage::decode_with_options(
657                    ::buffa::alloc::sync::Arc::clone(
658                        super::super::__buffa::reflect::descriptor_pool(),
659                    ),
660                    Self::__buffa_reflect_message_index(),
661                    &bytes,
662                    &options,
663                )
664                .expect("view re-encodes to bytes decodable against its own descriptor")
665        }
666    }
667    impl<'a> ::buffa_descriptor::reflect::ReflectElement for ApiView<'a> {
668        fn as_value_ref(&self) -> ::buffa_descriptor::reflect::ValueRef<'_> {
669            ::buffa_descriptor::reflect::ValueRef::Message(
670                ::buffa_descriptor::reflect::ReflectCow::Borrowed(self),
671            )
672        }
673    }
674    impl<'a> ApiView<'a> {
675        /// Memoized `MessageIndex` for this view's message type, resolved
676        /// once against the package's embedded descriptor pool. An inherent
677        /// associated fn (not a free fn) so sibling views in the same module
678        /// do not collide.
679        #[doc(hidden)]
680        fn __buffa_reflect_message_index() -> ::buffa_descriptor::MessageIndex {
681            static IDX: ::std::sync::OnceLock<::buffa_descriptor::MessageIndex> = ::std::sync::OnceLock::new();
682            *IDX
683                .get_or_init(|| {
684                    super::super::__buffa::reflect::descriptor_pool()
685                        .message_index(<Self as ::buffa::MessageName>::FULL_NAME)
686                        .expect(
687                            "generated view type is registered in the embedded descriptor pool",
688                        )
689                })
690        }
691    }
692};
693/// Method represents a method of an API interface.
694///
695/// New usages of this message as an alternative to MethodDescriptorProto are
696/// strongly discouraged. This message does not reliability preserve all
697/// information necessary to model the schema and preserve semantics. Instead
698/// make use of FileDescriptorSet which preserves the necessary information.
699#[derive(Clone, Debug, Default)]
700pub struct MethodView<'a> {
701    /// The simple name of this method.
702    ///
703    /// Field 1: `name`
704    pub name: &'a str,
705    /// A URL of the input message type.
706    ///
707    /// Field 2: `request_type_url`
708    pub request_type_url: &'a str,
709    /// If true, the request is streamed.
710    ///
711    /// Field 3: `request_streaming`
712    pub request_streaming: bool,
713    /// The URL of the output message type.
714    ///
715    /// Field 4: `response_type_url`
716    pub response_type_url: &'a str,
717    /// If true, the response is streamed.
718    ///
719    /// Field 5: `response_streaming`
720    pub response_streaming: bool,
721    /// Any metadata attached to the method.
722    ///
723    /// Field 6: `options`
724    pub options: ::buffa::RepeatedView<'a, super::super::__buffa::view::OptionView<'a>>,
725    /// The source syntax of this method.
726    ///
727    /// This field should be ignored, instead the syntax should be inherited from
728    /// Api. This is similar to Field and EnumValue.
729    ///
730    /// Field 7: `syntax`
731    pub syntax: ::buffa::EnumValue<super::super::Syntax>,
732    /// The source edition string, only valid when syntax is SYNTAX_EDITIONS.
733    ///
734    /// This field should be ignored, instead the edition should be inherited from
735    /// Api. This is similar to Field and EnumValue.
736    ///
737    /// Field 8: `edition`
738    pub edition: &'a str,
739    pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
740}
741impl<'a> ::buffa::MessageView<'a> for MethodView<'a> {
742    type Owned = super::super::Method;
743    fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
744        let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT);
745        let __elem = ::core::cell::Cell::new(::buffa::DEFAULT_ELEMENT_MEMORY_LIMIT);
746        <Self as ::buffa::MessageView>::decode_view_ctx(
747            buf,
748            ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit)
749                .with_element_memory(&__elem),
750        )
751    }
752    fn decode_view_with_ctx(
753        buf: &'a [u8],
754        ctx: ::buffa::DecodeContext<'_>,
755    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
756        <Self as ::buffa::MessageView>::decode_view_ctx(buf, ctx)
757    }
758    #[inline]
759    fn merge_view_field(
760        &mut self,
761        tag: ::buffa::encoding::Tag,
762        cur: &'a [u8],
763        before_tag: &'a [u8],
764        ctx: ::buffa::DecodeContext<'_>,
765    ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> {
766        let _ = ctx;
767        #[allow(unused_variables)]
768        let view = self;
769        let mut cur = cur;
770        match tag.field_number() {
771            1u32 => {
772                ::buffa::encoding::check_wire_type(
773                    tag,
774                    ::buffa::encoding::WireType::LengthDelimited,
775                )?;
776                view.name = ::buffa::types::borrow_str(&mut cur)?;
777            }
778            2u32 => {
779                ::buffa::encoding::check_wire_type(
780                    tag,
781                    ::buffa::encoding::WireType::LengthDelimited,
782                )?;
783                view.request_type_url = ::buffa::types::borrow_str(&mut cur)?;
784            }
785            3u32 => {
786                ::buffa::encoding::check_wire_type(
787                    tag,
788                    ::buffa::encoding::WireType::Varint,
789                )?;
790                view.request_streaming = ::buffa::types::decode_bool(&mut cur)?;
791            }
792            4u32 => {
793                ::buffa::encoding::check_wire_type(
794                    tag,
795                    ::buffa::encoding::WireType::LengthDelimited,
796                )?;
797                view.response_type_url = ::buffa::types::borrow_str(&mut cur)?;
798            }
799            5u32 => {
800                ::buffa::encoding::check_wire_type(
801                    tag,
802                    ::buffa::encoding::WireType::Varint,
803                )?;
804                view.response_streaming = ::buffa::types::decode_bool(&mut cur)?;
805            }
806            7u32 => {
807                ::buffa::encoding::check_wire_type(
808                    tag,
809                    ::buffa::encoding::WireType::Varint,
810                )?;
811                view.syntax = ::buffa::EnumValue::from(
812                    ::buffa::types::decode_int32(&mut cur)?,
813                );
814            }
815            8u32 => {
816                ::buffa::encoding::check_wire_type(
817                    tag,
818                    ::buffa::encoding::WireType::LengthDelimited,
819                )?;
820                view.edition = ::buffa::types::borrow_str(&mut cur)?;
821            }
822            6u32 => {
823                ::buffa::encoding::check_wire_type(
824                    tag,
825                    ::buffa::encoding::WireType::LengthDelimited,
826                )?;
827                let __sub_ctx = ctx.descend()?;
828                let sub = ::buffa::types::borrow_bytes(&mut cur)?;
829                ctx.register_element_memory(
830                    ::core::mem::size_of::<super::super::__buffa::view::OptionView>(),
831                )?;
832                view.options
833                    .push(
834                        <super::super::__buffa::view::OptionView as ::buffa::MessageView>::decode_view_ctx(
835                            sub,
836                            __sub_ctx,
837                        )?,
838                    );
839            }
840            _ => {
841                ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?;
842                let span_len = before_tag.len() - cur.len();
843                view.__buffa_unknown_fields.push_record(before_tag, span_len, ctx)?;
844            }
845        }
846        ::core::result::Result::Ok(cur)
847    }
848    fn to_owned_message(
849        &self,
850    ) -> ::core::result::Result<super::super::Method, ::buffa::DecodeError> {
851        self.to_owned_from_source(None)
852    }
853    #[allow(clippy::useless_conversion, clippy::needless_update)]
854    fn to_owned_from_source(
855        &self,
856        __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>,
857    ) -> ::core::result::Result<super::super::Method, ::buffa::DecodeError> {
858        #[allow(unused_imports)]
859        use ::buffa::alloc::string::ToString as _;
860        let _ = __buffa_src;
861        ::core::result::Result::Ok(super::super::Method {
862            name: self.name.to_string(),
863            request_type_url: self.request_type_url.to_string(),
864            request_streaming: self.request_streaming,
865            response_type_url: self.response_type_url.to_string(),
866            response_streaming: self.response_streaming,
867            options: self
868                .options
869                .iter()
870                .map(|v| v.to_owned_from_source(__buffa_src))
871                .collect::<::core::result::Result<_, ::buffa::DecodeError>>()?,
872            syntax: self.syntax,
873            edition: self.edition.to_string(),
874            __buffa_unknown_fields: self.__buffa_unknown_fields.to_owned()?.into(),
875            ..::core::default::Default::default()
876        })
877    }
878}
879impl<'a> ::buffa::ViewEncode<'a> for MethodView<'a> {
880    #[allow(clippy::needless_borrow, clippy::let_and_return)]
881    fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 {
882        #[allow(unused_imports)]
883        use ::buffa::Enumeration as _;
884        let mut size = 0u64;
885        if !self.name.is_empty() {
886            size += 1u64 + ::buffa::types::string_encoded_len(&self.name) as u64;
887        }
888        if !self.request_type_url.is_empty() {
889            size
890                += 1u64
891                    + ::buffa::types::string_encoded_len(&self.request_type_url) as u64;
892        }
893        if self.request_streaming {
894            size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64;
895        }
896        if !self.response_type_url.is_empty() {
897            size
898                += 1u64
899                    + ::buffa::types::string_encoded_len(&self.response_type_url) as u64;
900        }
901        if self.response_streaming {
902            size += 1u64 + ::buffa::types::BOOL_ENCODED_LEN as u64;
903        }
904        for v in &self.options {
905            let __slot = __cache.reserve();
906            let inner_size = v.compute_size(__cache);
907            __cache.set(__slot, inner_size);
908            size
909                += 1u64 + ::buffa::encoding::varint_len(inner_size as u64) as u64
910                    + inner_size as u64;
911        }
912        {
913            let val = self.syntax.to_i32();
914            if val != 0 {
915                size += 1u64 + ::buffa::types::int32_encoded_len(val) as u64;
916            }
917        }
918        if !self.edition.is_empty() {
919            size += 1u64 + ::buffa::types::string_encoded_len(&self.edition) as u64;
920        }
921        size += self.__buffa_unknown_fields.encoded_len() as u64;
922        ::buffa::saturate_size(size)
923    }
924    #[allow(clippy::needless_borrow)]
925    fn write_to(
926        &self,
927        __cache: &mut ::buffa::SizeCache,
928        buf: &mut impl ::buffa::EncodeSink,
929    ) {
930        #[allow(unused_imports)]
931        use ::buffa::Enumeration as _;
932        if !self.name.is_empty() {
933            ::buffa::types::put_string_field(1u32, &self.name, buf);
934        }
935        if !self.request_type_url.is_empty() {
936            ::buffa::types::put_string_field(2u32, &self.request_type_url, buf);
937        }
938        if self.request_streaming {
939            ::buffa::types::put_bool_field(3u32, self.request_streaming, buf);
940        }
941        if !self.response_type_url.is_empty() {
942            ::buffa::types::put_string_field(4u32, &self.response_type_url, buf);
943        }
944        if self.response_streaming {
945            ::buffa::types::put_bool_field(5u32, self.response_streaming, buf);
946        }
947        for v in &self.options {
948            ::buffa::types::put_len_delimited_header(
949                6u32,
950                u64::from(__cache.consume_next()),
951                buf,
952            );
953            v.write_to(__cache, buf);
954        }
955        {
956            let val = self.syntax.to_i32();
957            if val != 0 {
958                ::buffa::types::put_int32_field(7u32, val, buf);
959            }
960        }
961        if !self.edition.is_empty() {
962            ::buffa::types::put_string_field(8u32, &self.edition, buf);
963        }
964        self.__buffa_unknown_fields.write_to(buf);
965    }
966}
967impl<'a> ::buffa::MessageName for MethodView<'a> {
968    const PACKAGE: &'static str = "google.protobuf";
969    const NAME: &'static str = "Method";
970    const FULL_NAME: &'static str = "google.protobuf.Method";
971    const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.Method";
972}
973::buffa::impl_default_view_instance!(MethodView);
974::buffa::impl_view_reborrow!(MethodView);
975/** Self-contained, `'static` owned view of a `Method` message.
976
977 Wraps [`::buffa::OwnedView`]`<`[`MethodView`]`<'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.
978
979 Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`MethodView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/
980#[derive(Clone, Debug)]
981pub struct MethodOwnedView(::buffa::OwnedView<MethodView<'static>>);
982impl MethodOwnedView {
983    /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer.
984    ///
985    /// The view borrows directly from the buffer's data; the buffer is
986    /// retained inside the returned handle.
987    ///
988    /// # Errors
989    ///
990    /// Returns [`::buffa::DecodeError`] if the buffer contains invalid
991    /// protobuf data.
992    pub fn decode(
993        bytes: ::buffa::bytes::Bytes,
994    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
995        ::core::result::Result::Ok(MethodOwnedView(::buffa::OwnedView::decode(bytes)?))
996    }
997    /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit,
998    /// max message size).
999    ///
1000    /// # Errors
1001    ///
1002    /// Returns [`::buffa::DecodeError`] if the buffer is invalid or
1003    /// exceeds the configured limits.
1004    pub fn decode_with_options(
1005        bytes: ::buffa::bytes::Bytes,
1006        opts: &::buffa::DecodeOptions,
1007    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
1008        ::core::result::Result::Ok(
1009            MethodOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?),
1010        )
1011    }
1012    /// Build from an owned message via an encode → decode round-trip.
1013    ///
1014    /// # Errors
1015    ///
1016    /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the
1017    /// message's encoded size exceeds the 2 GiB protobuf limit, or
1018    /// another [`::buffa::DecodeError`] if the re-encoded bytes are
1019    /// somehow invalid (should not happen for well-formed messages).
1020    pub fn from_owned(
1021        msg: &super::super::Method,
1022    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
1023        ::core::result::Result::Ok(MethodOwnedView(::buffa::OwnedView::from_owned(msg)?))
1024    }
1025    /// Borrow the full [`MethodView`] with its lifetime tied to `&self`.
1026    #[must_use]
1027    pub fn view(&self) -> &MethodView<'_> {
1028        self.0.reborrow()
1029    }
1030    /// Convert to the owned message type.
1031    ///
1032    /// Infallible: this type's constructors wire-decode their
1033    /// buffer, and a view produced by wire decoding always
1034    /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`],
1035    /// whose contract also governs handles converted from a raw
1036    /// [`::buffa::OwnedView`].
1037    #[must_use]
1038    pub fn to_owned_message(&self) -> super::super::Method {
1039        self.0.to_owned_message()
1040    }
1041    /// The underlying bytes buffer.
1042    #[must_use]
1043    pub fn bytes(&self) -> &::buffa::bytes::Bytes {
1044        self.0.bytes()
1045    }
1046    /// Consume the handle, returning the underlying bytes buffer.
1047    #[must_use]
1048    pub fn into_bytes(self) -> ::buffa::bytes::Bytes {
1049        self.0.into_bytes()
1050    }
1051    /// The simple name of this method.
1052    ///
1053    /// Field 1: `name`
1054    #[must_use]
1055    pub fn name(&self) -> &'_ str {
1056        self.0.reborrow().name
1057    }
1058    /// A URL of the input message type.
1059    ///
1060    /// Field 2: `request_type_url`
1061    #[must_use]
1062    pub fn request_type_url(&self) -> &'_ str {
1063        self.0.reborrow().request_type_url
1064    }
1065    /// If true, the request is streamed.
1066    ///
1067    /// Field 3: `request_streaming`
1068    #[must_use]
1069    pub fn request_streaming(&self) -> bool {
1070        self.0.reborrow().request_streaming
1071    }
1072    /// The URL of the output message type.
1073    ///
1074    /// Field 4: `response_type_url`
1075    #[must_use]
1076    pub fn response_type_url(&self) -> &'_ str {
1077        self.0.reborrow().response_type_url
1078    }
1079    /// If true, the response is streamed.
1080    ///
1081    /// Field 5: `response_streaming`
1082    #[must_use]
1083    pub fn response_streaming(&self) -> bool {
1084        self.0.reborrow().response_streaming
1085    }
1086    /// Any metadata attached to the method.
1087    ///
1088    /// Field 6: `options`
1089    #[must_use]
1090    pub fn options(
1091        &self,
1092    ) -> &::buffa::RepeatedView<'_, super::super::__buffa::view::OptionView<'_>> {
1093        &self.0.reborrow().options
1094    }
1095    /// The source syntax of this method.
1096    ///
1097    /// This field should be ignored, instead the syntax should be inherited from
1098    /// Api. This is similar to Field and EnumValue.
1099    ///
1100    /// Field 7: `syntax`
1101    #[must_use]
1102    pub fn syntax(&self) -> ::buffa::EnumValue<super::super::Syntax> {
1103        self.0.reborrow().syntax
1104    }
1105    /// The source edition string, only valid when syntax is SYNTAX_EDITIONS.
1106    ///
1107    /// This field should be ignored, instead the edition should be inherited from
1108    /// Api. This is similar to Field and EnumValue.
1109    ///
1110    /// Field 8: `edition`
1111    #[must_use]
1112    pub fn edition(&self) -> &'_ str {
1113        self.0.reborrow().edition
1114    }
1115}
1116impl ::core::convert::From<::buffa::OwnedView<MethodView<'static>>> for MethodOwnedView {
1117    fn from(inner: ::buffa::OwnedView<MethodView<'static>>) -> Self {
1118        MethodOwnedView(inner)
1119    }
1120}
1121impl ::core::convert::From<MethodOwnedView> for ::buffa::OwnedView<MethodView<'static>> {
1122    fn from(wrapper: MethodOwnedView) -> Self {
1123        wrapper.0
1124    }
1125}
1126impl ::core::convert::AsRef<::buffa::OwnedView<MethodView<'static>>>
1127for MethodOwnedView {
1128    fn as_ref(&self) -> &::buffa::OwnedView<MethodView<'static>> {
1129        &self.0
1130    }
1131}
1132impl ::buffa::HasMessageView for super::super::Method {
1133    type View<'a> = MethodView<'a>;
1134    type ViewHandle = MethodOwnedView;
1135}
1136#[cfg(feature = "reflect")]
1137const _: () = {
1138    impl<'a> ::buffa_descriptor::reflect::ReflectMessage for MethodView<'a> {
1139        fn message_descriptor(&self) -> &::buffa_descriptor::MessageDescriptor {
1140            super::super::__buffa::reflect::descriptor_pool()
1141                .message(Self::__buffa_reflect_message_index())
1142        }
1143        fn pool(
1144            &self,
1145        ) -> &::buffa::alloc::sync::Arc<::buffa_descriptor::DescriptorPool> {
1146            super::super::__buffa::reflect::descriptor_pool()
1147        }
1148        fn get(
1149            &self,
1150            field: &::buffa_descriptor::FieldDescriptor,
1151        ) -> ::buffa_descriptor::reflect::ValueRef<'_> {
1152            #[allow(unused_imports)]
1153            use ::buffa::Enumeration as _;
1154            match field.number() {
1155                1u32 => ::buffa_descriptor::reflect::ValueRef::String(self.name),
1156                2u32 => {
1157                    ::buffa_descriptor::reflect::ValueRef::String(self.request_type_url)
1158                }
1159                3u32 => {
1160                    ::buffa_descriptor::reflect::ValueRef::Bool(self.request_streaming)
1161                }
1162                4u32 => {
1163                    ::buffa_descriptor::reflect::ValueRef::String(self.response_type_url)
1164                }
1165                5u32 => {
1166                    ::buffa_descriptor::reflect::ValueRef::Bool(self.response_streaming)
1167                }
1168                6u32 => ::buffa_descriptor::reflect::ValueRef::List(&self.options),
1169                7u32 => {
1170                    ::buffa_descriptor::reflect::ValueRef::EnumNumber(
1171                        self.syntax.to_i32(),
1172                    )
1173                }
1174                8u32 => ::buffa_descriptor::reflect::ValueRef::String(self.edition),
1175                _ => {
1176                    ::core::debug_assert!(
1177                        false,
1178                        "field number {} is not a member of this view's reflect get()",
1179                        field.number(),
1180                    );
1181                    ::buffa_descriptor::reflect::ValueRef::Bool(false)
1182                }
1183            }
1184        }
1185        fn has(&self, field: &::buffa_descriptor::FieldDescriptor) -> bool {
1186            match field.number() {
1187                1u32 => !self.name.is_empty(),
1188                2u32 => !self.request_type_url.is_empty(),
1189                3u32 => self.request_streaming,
1190                4u32 => !self.response_type_url.is_empty(),
1191                5u32 => self.response_streaming,
1192                6u32 => !::buffa::RepeatedView::is_empty(&self.options),
1193                7u32 => self.syntax.to_i32() != 0,
1194                8u32 => !self.edition.is_empty(),
1195                _ => false,
1196            }
1197        }
1198        fn for_each_set(
1199            &self,
1200            f: &mut dyn ::core::ops::FnMut(
1201                &::buffa_descriptor::FieldDescriptor,
1202                ::buffa_descriptor::reflect::ValueRef<'_>,
1203            ),
1204        ) {
1205            let md = ::buffa_descriptor::reflect::ReflectMessage::message_descriptor(
1206                self,
1207            );
1208            for fd in md.fields() {
1209                if ::buffa_descriptor::reflect::ReflectMessage::has(self, fd) {
1210                    f(fd, ::buffa_descriptor::reflect::ReflectMessage::get(self, fd));
1211                }
1212            }
1213        }
1214        fn to_dynamic(&self) -> ::buffa_descriptor::reflect::DynamicMessage {
1215            let bytes = ::buffa::ViewEncode::encode_to_vec(self);
1216            let options = ::buffa::DecodeOptions::new()
1217                .with_element_memory_limit(
1218                    bytes
1219                        .len()
1220                        .saturating_mul(128)
1221                        .max(::buffa::DEFAULT_ELEMENT_MEMORY_LIMIT),
1222                )
1223                .with_unknown_field_limit(
1224                    bytes.len().max(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT),
1225                );
1226            ::buffa_descriptor::reflect::DynamicMessage::decode_with_options(
1227                    ::buffa::alloc::sync::Arc::clone(
1228                        super::super::__buffa::reflect::descriptor_pool(),
1229                    ),
1230                    Self::__buffa_reflect_message_index(),
1231                    &bytes,
1232                    &options,
1233                )
1234                .expect("view re-encodes to bytes decodable against its own descriptor")
1235        }
1236    }
1237    impl<'a> ::buffa_descriptor::reflect::ReflectElement for MethodView<'a> {
1238        fn as_value_ref(&self) -> ::buffa_descriptor::reflect::ValueRef<'_> {
1239            ::buffa_descriptor::reflect::ValueRef::Message(
1240                ::buffa_descriptor::reflect::ReflectCow::Borrowed(self),
1241            )
1242        }
1243    }
1244    impl<'a> MethodView<'a> {
1245        /// Memoized `MessageIndex` for this view's message type, resolved
1246        /// once against the package's embedded descriptor pool. An inherent
1247        /// associated fn (not a free fn) so sibling views in the same module
1248        /// do not collide.
1249        #[doc(hidden)]
1250        fn __buffa_reflect_message_index() -> ::buffa_descriptor::MessageIndex {
1251            static IDX: ::std::sync::OnceLock<::buffa_descriptor::MessageIndex> = ::std::sync::OnceLock::new();
1252            *IDX
1253                .get_or_init(|| {
1254                    super::super::__buffa::reflect::descriptor_pool()
1255                        .message_index(<Self as ::buffa::MessageName>::FULL_NAME)
1256                        .expect(
1257                            "generated view type is registered in the embedded descriptor pool",
1258                        )
1259                })
1260        }
1261    }
1262};
1263/// Declares an API Interface to be included in this interface. The including
1264/// interface must redeclare all the methods from the included interface, but
1265/// documentation and options are inherited as follows:
1266///
1267/// - If after comment and whitespace stripping, the documentation
1268///   string of the redeclared method is empty, it will be inherited
1269///   from the original method.
1270///
1271/// - Each annotation belonging to the service config (http,
1272///   visibility) which is not set in the redeclared method will be
1273///   inherited.
1274///
1275/// - If an http annotation is inherited, the path pattern will be
1276///   modified as follows. Any version prefix will be replaced by the
1277///   version of the including interface plus the \[root\]\[\] path if
1278///   specified.
1279///
1280/// Example of a simple mixin:
1281///
1282/// ```text
1283/// package google.acl.v1;
1284/// service AccessControl {
1285///   // Get the underlying ACL object.
1286///   rpc GetAcl(GetAclRequest) returns (Acl) {
1287///     option (google.api.http).get = "/v1/{resource=**}:getAcl";
1288///   }
1289/// }
1290///
1291/// package google.storage.v2;
1292/// service Storage {
1293///   rpc GetAcl(GetAclRequest) returns (Acl);
1294///
1295///   // Get a data record.
1296///   rpc GetData(GetDataRequest) returns (Data) {
1297///     option (google.api.http).get = "/v2/{resource=**}";
1298///   }
1299/// }
1300/// ```
1301///
1302/// Example of a mixin configuration:
1303///
1304/// ```text
1305/// apis:
1306/// - name: google.storage.v2.Storage
1307///   mixins:
1308///   - name: google.acl.v1.AccessControl
1309/// ```
1310///
1311/// The mixin construct implies that all methods in `AccessControl` are
1312/// also declared with same name and request/response types in
1313/// `Storage`. A documentation generator or annotation processor will
1314/// see the effective `Storage.GetAcl` method after inheriting
1315/// documentation and annotations as follows:
1316///
1317/// ```text
1318/// service Storage {
1319///   // Get the underlying ACL object.
1320///   rpc GetAcl(GetAclRequest) returns (Acl) {
1321///     option (google.api.http).get = "/v2/{resource=**}:getAcl";
1322///   }
1323///   ...
1324/// }
1325/// ```
1326///
1327/// Note how the version in the path pattern changed from `v1` to `v2`.
1328///
1329/// If the `root` field in the mixin is specified, it should be a
1330/// relative path under which inherited HTTP paths are placed. Example:
1331///
1332/// ```text
1333/// apis:
1334/// - name: google.storage.v2.Storage
1335///   mixins:
1336///   - name: google.acl.v1.AccessControl
1337///     root: acls
1338/// ```
1339///
1340/// This implies the following inherited HTTP annotation:
1341///
1342/// ```text
1343/// service Storage {
1344///   // Get the underlying ACL object.
1345///   rpc GetAcl(GetAclRequest) returns (Acl) {
1346///     option (google.api.http).get = "/v2/acls/{resource=**}:getAcl";
1347///   }
1348///   ...
1349/// }
1350/// ```
1351#[derive(Clone, Debug, Default)]
1352pub struct MixinView<'a> {
1353    /// The fully qualified name of the interface which is included.
1354    ///
1355    /// Field 1: `name`
1356    pub name: &'a str,
1357    /// If non-empty specifies a path under which inherited HTTP paths
1358    /// are rooted.
1359    ///
1360    /// Field 2: `root`
1361    pub root: &'a str,
1362    pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
1363}
1364impl<'a> ::buffa::MessageView<'a> for MixinView<'a> {
1365    type Owned = super::super::Mixin;
1366    fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
1367        let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT);
1368        let __elem = ::core::cell::Cell::new(::buffa::DEFAULT_ELEMENT_MEMORY_LIMIT);
1369        <Self as ::buffa::MessageView>::decode_view_ctx(
1370            buf,
1371            ::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit)
1372                .with_element_memory(&__elem),
1373        )
1374    }
1375    fn decode_view_with_ctx(
1376        buf: &'a [u8],
1377        ctx: ::buffa::DecodeContext<'_>,
1378    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
1379        <Self as ::buffa::MessageView>::decode_view_ctx(buf, ctx)
1380    }
1381    #[inline]
1382    fn merge_view_field(
1383        &mut self,
1384        tag: ::buffa::encoding::Tag,
1385        cur: &'a [u8],
1386        before_tag: &'a [u8],
1387        ctx: ::buffa::DecodeContext<'_>,
1388    ) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> {
1389        let _ = ctx;
1390        #[allow(unused_variables)]
1391        let view = self;
1392        let mut cur = cur;
1393        match tag.field_number() {
1394            1u32 => {
1395                ::buffa::encoding::check_wire_type(
1396                    tag,
1397                    ::buffa::encoding::WireType::LengthDelimited,
1398                )?;
1399                view.name = ::buffa::types::borrow_str(&mut cur)?;
1400            }
1401            2u32 => {
1402                ::buffa::encoding::check_wire_type(
1403                    tag,
1404                    ::buffa::encoding::WireType::LengthDelimited,
1405                )?;
1406                view.root = ::buffa::types::borrow_str(&mut cur)?;
1407            }
1408            _ => {
1409                ::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?;
1410                let span_len = before_tag.len() - cur.len();
1411                view.__buffa_unknown_fields.push_record(before_tag, span_len, ctx)?;
1412            }
1413        }
1414        ::core::result::Result::Ok(cur)
1415    }
1416    fn to_owned_message(
1417        &self,
1418    ) -> ::core::result::Result<super::super::Mixin, ::buffa::DecodeError> {
1419        self.to_owned_from_source(None)
1420    }
1421    #[allow(clippy::useless_conversion, clippy::needless_update)]
1422    fn to_owned_from_source(
1423        &self,
1424        __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>,
1425    ) -> ::core::result::Result<super::super::Mixin, ::buffa::DecodeError> {
1426        #[allow(unused_imports)]
1427        use ::buffa::alloc::string::ToString as _;
1428        let _ = __buffa_src;
1429        ::core::result::Result::Ok(super::super::Mixin {
1430            name: self.name.to_string(),
1431            root: self.root.to_string(),
1432            __buffa_unknown_fields: self.__buffa_unknown_fields.to_owned()?.into(),
1433            ..::core::default::Default::default()
1434        })
1435    }
1436}
1437impl<'a> ::buffa::ViewEncode<'a> for MixinView<'a> {
1438    #[allow(clippy::needless_borrow, clippy::let_and_return)]
1439    fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 {
1440        #[allow(unused_imports)]
1441        use ::buffa::Enumeration as _;
1442        let mut size = 0u64;
1443        if !self.name.is_empty() {
1444            size += 1u64 + ::buffa::types::string_encoded_len(&self.name) as u64;
1445        }
1446        if !self.root.is_empty() {
1447            size += 1u64 + ::buffa::types::string_encoded_len(&self.root) as u64;
1448        }
1449        size += self.__buffa_unknown_fields.encoded_len() as u64;
1450        ::buffa::saturate_size(size)
1451    }
1452    #[allow(clippy::needless_borrow)]
1453    fn write_to(
1454        &self,
1455        _cache: &mut ::buffa::SizeCache,
1456        buf: &mut impl ::buffa::EncodeSink,
1457    ) {
1458        #[allow(unused_imports)]
1459        use ::buffa::Enumeration as _;
1460        if !self.name.is_empty() {
1461            ::buffa::types::put_string_field(1u32, &self.name, buf);
1462        }
1463        if !self.root.is_empty() {
1464            ::buffa::types::put_string_field(2u32, &self.root, buf);
1465        }
1466        self.__buffa_unknown_fields.write_to(buf);
1467    }
1468}
1469impl<'a> ::buffa::MessageName for MixinView<'a> {
1470    const PACKAGE: &'static str = "google.protobuf";
1471    const NAME: &'static str = "Mixin";
1472    const FULL_NAME: &'static str = "google.protobuf.Mixin";
1473    const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.Mixin";
1474}
1475::buffa::impl_default_view_instance!(MixinView);
1476::buffa::impl_view_reborrow!(MixinView);
1477/** Self-contained, `'static` owned view of a `Mixin` message.
1478
1479 Wraps [`::buffa::OwnedView`]`<`[`MixinView`]`<'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.
1480
1481 Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`MixinView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/
1482#[derive(Clone, Debug)]
1483pub struct MixinOwnedView(::buffa::OwnedView<MixinView<'static>>);
1484impl MixinOwnedView {
1485    /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer.
1486    ///
1487    /// The view borrows directly from the buffer's data; the buffer is
1488    /// retained inside the returned handle.
1489    ///
1490    /// # Errors
1491    ///
1492    /// Returns [`::buffa::DecodeError`] if the buffer contains invalid
1493    /// protobuf data.
1494    pub fn decode(
1495        bytes: ::buffa::bytes::Bytes,
1496    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
1497        ::core::result::Result::Ok(MixinOwnedView(::buffa::OwnedView::decode(bytes)?))
1498    }
1499    /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit,
1500    /// max message size).
1501    ///
1502    /// # Errors
1503    ///
1504    /// Returns [`::buffa::DecodeError`] if the buffer is invalid or
1505    /// exceeds the configured limits.
1506    pub fn decode_with_options(
1507        bytes: ::buffa::bytes::Bytes,
1508        opts: &::buffa::DecodeOptions,
1509    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
1510        ::core::result::Result::Ok(
1511            MixinOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?),
1512        )
1513    }
1514    /// Build from an owned message via an encode → decode round-trip.
1515    ///
1516    /// # Errors
1517    ///
1518    /// Returns [`::buffa::DecodeError::MessageTooLarge`] if the
1519    /// message's encoded size exceeds the 2 GiB protobuf limit, or
1520    /// another [`::buffa::DecodeError`] if the re-encoded bytes are
1521    /// somehow invalid (should not happen for well-formed messages).
1522    pub fn from_owned(
1523        msg: &super::super::Mixin,
1524    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
1525        ::core::result::Result::Ok(MixinOwnedView(::buffa::OwnedView::from_owned(msg)?))
1526    }
1527    /// Borrow the full [`MixinView`] with its lifetime tied to `&self`.
1528    #[must_use]
1529    pub fn view(&self) -> &MixinView<'_> {
1530        self.0.reborrow()
1531    }
1532    /// Convert to the owned message type.
1533    ///
1534    /// Infallible: this type's constructors wire-decode their
1535    /// buffer, and a view produced by wire decoding always
1536    /// converts. Delegates to [`::buffa::OwnedView::to_owned_message`],
1537    /// whose contract also governs handles converted from a raw
1538    /// [`::buffa::OwnedView`].
1539    #[must_use]
1540    pub fn to_owned_message(&self) -> super::super::Mixin {
1541        self.0.to_owned_message()
1542    }
1543    /// The underlying bytes buffer.
1544    #[must_use]
1545    pub fn bytes(&self) -> &::buffa::bytes::Bytes {
1546        self.0.bytes()
1547    }
1548    /// Consume the handle, returning the underlying bytes buffer.
1549    #[must_use]
1550    pub fn into_bytes(self) -> ::buffa::bytes::Bytes {
1551        self.0.into_bytes()
1552    }
1553    /// The fully qualified name of the interface which is included.
1554    ///
1555    /// Field 1: `name`
1556    #[must_use]
1557    pub fn name(&self) -> &'_ str {
1558        self.0.reborrow().name
1559    }
1560    /// If non-empty specifies a path under which inherited HTTP paths
1561    /// are rooted.
1562    ///
1563    /// Field 2: `root`
1564    #[must_use]
1565    pub fn root(&self) -> &'_ str {
1566        self.0.reborrow().root
1567    }
1568}
1569impl ::core::convert::From<::buffa::OwnedView<MixinView<'static>>> for MixinOwnedView {
1570    fn from(inner: ::buffa::OwnedView<MixinView<'static>>) -> Self {
1571        MixinOwnedView(inner)
1572    }
1573}
1574impl ::core::convert::From<MixinOwnedView> for ::buffa::OwnedView<MixinView<'static>> {
1575    fn from(wrapper: MixinOwnedView) -> Self {
1576        wrapper.0
1577    }
1578}
1579impl ::core::convert::AsRef<::buffa::OwnedView<MixinView<'static>>> for MixinOwnedView {
1580    fn as_ref(&self) -> &::buffa::OwnedView<MixinView<'static>> {
1581        &self.0
1582    }
1583}
1584impl ::buffa::HasMessageView for super::super::Mixin {
1585    type View<'a> = MixinView<'a>;
1586    type ViewHandle = MixinOwnedView;
1587}
1588#[cfg(feature = "reflect")]
1589const _: () = {
1590    impl<'a> ::buffa_descriptor::reflect::ReflectMessage for MixinView<'a> {
1591        fn message_descriptor(&self) -> &::buffa_descriptor::MessageDescriptor {
1592            super::super::__buffa::reflect::descriptor_pool()
1593                .message(Self::__buffa_reflect_message_index())
1594        }
1595        fn pool(
1596            &self,
1597        ) -> &::buffa::alloc::sync::Arc<::buffa_descriptor::DescriptorPool> {
1598            super::super::__buffa::reflect::descriptor_pool()
1599        }
1600        fn get(
1601            &self,
1602            field: &::buffa_descriptor::FieldDescriptor,
1603        ) -> ::buffa_descriptor::reflect::ValueRef<'_> {
1604            #[allow(unused_imports)]
1605            use ::buffa::Enumeration as _;
1606            match field.number() {
1607                1u32 => ::buffa_descriptor::reflect::ValueRef::String(self.name),
1608                2u32 => ::buffa_descriptor::reflect::ValueRef::String(self.root),
1609                _ => {
1610                    ::core::debug_assert!(
1611                        false,
1612                        "field number {} is not a member of this view's reflect get()",
1613                        field.number(),
1614                    );
1615                    ::buffa_descriptor::reflect::ValueRef::Bool(false)
1616                }
1617            }
1618        }
1619        fn has(&self, field: &::buffa_descriptor::FieldDescriptor) -> bool {
1620            match field.number() {
1621                1u32 => !self.name.is_empty(),
1622                2u32 => !self.root.is_empty(),
1623                _ => false,
1624            }
1625        }
1626        fn for_each_set(
1627            &self,
1628            f: &mut dyn ::core::ops::FnMut(
1629                &::buffa_descriptor::FieldDescriptor,
1630                ::buffa_descriptor::reflect::ValueRef<'_>,
1631            ),
1632        ) {
1633            let md = ::buffa_descriptor::reflect::ReflectMessage::message_descriptor(
1634                self,
1635            );
1636            for fd in md.fields() {
1637                if ::buffa_descriptor::reflect::ReflectMessage::has(self, fd) {
1638                    f(fd, ::buffa_descriptor::reflect::ReflectMessage::get(self, fd));
1639                }
1640            }
1641        }
1642        fn to_dynamic(&self) -> ::buffa_descriptor::reflect::DynamicMessage {
1643            let bytes = ::buffa::ViewEncode::encode_to_vec(self);
1644            let options = ::buffa::DecodeOptions::new()
1645                .with_element_memory_limit(
1646                    bytes
1647                        .len()
1648                        .saturating_mul(128)
1649                        .max(::buffa::DEFAULT_ELEMENT_MEMORY_LIMIT),
1650                )
1651                .with_unknown_field_limit(
1652                    bytes.len().max(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT),
1653                );
1654            ::buffa_descriptor::reflect::DynamicMessage::decode_with_options(
1655                    ::buffa::alloc::sync::Arc::clone(
1656                        super::super::__buffa::reflect::descriptor_pool(),
1657                    ),
1658                    Self::__buffa_reflect_message_index(),
1659                    &bytes,
1660                    &options,
1661                )
1662                .expect("view re-encodes to bytes decodable against its own descriptor")
1663        }
1664    }
1665    impl<'a> ::buffa_descriptor::reflect::ReflectElement for MixinView<'a> {
1666        fn as_value_ref(&self) -> ::buffa_descriptor::reflect::ValueRef<'_> {
1667            ::buffa_descriptor::reflect::ValueRef::Message(
1668                ::buffa_descriptor::reflect::ReflectCow::Borrowed(self),
1669            )
1670        }
1671    }
1672    impl<'a> MixinView<'a> {
1673        /// Memoized `MessageIndex` for this view's message type, resolved
1674        /// once against the package's embedded descriptor pool. An inherent
1675        /// associated fn (not a free fn) so sibling views in the same module
1676        /// do not collide.
1677        #[doc(hidden)]
1678        fn __buffa_reflect_message_index() -> ::buffa_descriptor::MessageIndex {
1679            static IDX: ::std::sync::OnceLock<::buffa_descriptor::MessageIndex> = ::std::sync::OnceLock::new();
1680            *IDX
1681                .get_or_init(|| {
1682                    super::super::__buffa::reflect::descriptor_pool()
1683                        .message_index(<Self as ::buffa::MessageName>::FULL_NAME)
1684                        .expect(
1685                            "generated view type is registered in the embedded descriptor pool",
1686                        )
1687                })
1688        }
1689    }
1690};