Skip to main content

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

1// @generated by buffa-codegen. DO NOT EDIT.
2// source: google/protobuf/struct.proto
3
4/// `Struct` represents a structured data value, consisting of fields
5/// which map to dynamically typed values. In some languages, `Struct`
6/// might be supported by a native representation. For example, in
7/// scripting languages like JS a struct is represented as an
8/// object. The details of that representation are described together
9/// with the proto support for the language.
10///
11/// The JSON representation for `Struct` is JSON object.
12#[derive(Clone, Debug, Default)]
13pub struct StructView<'a> {
14    /// Unordered map of dynamically typed values.
15    ///
16    /// Field 1: `fields` (map)
17    pub fields: ::buffa::MapView<
18        'a,
19        &'a str,
20        super::super::__buffa::view::ValueView<'a>,
21    >,
22    pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
23}
24impl<'a> StructView<'a> {
25    /// Decode from `buf`, enforcing a recursion depth limit for nested messages.
26    ///
27    /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`]
28    /// and by generated sub-message decode arms with `depth - 1`.
29    ///
30    /// **Not part of the public API.** Named with a leading underscore to
31    /// signal that it is for generated-code use only.
32    #[doc(hidden)]
33    pub fn _decode_depth(
34        buf: &'a [u8],
35        depth: u32,
36    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
37        let mut view = Self::default();
38        view._merge_into_view(buf, depth)?;
39        ::core::result::Result::Ok(view)
40    }
41    /// Merge fields from `buf` into this view (proto merge semantics).
42    ///
43    /// Repeated fields append; singular fields last-wins; singular
44    /// MESSAGE fields merge recursively. Used by sub-message decode
45    /// arms when the same field appears multiple times on the wire.
46    ///
47    /// **Not part of the public API.**
48    #[doc(hidden)]
49    pub fn _merge_into_view(
50        &mut self,
51        buf: &'a [u8],
52        depth: u32,
53    ) -> ::core::result::Result<(), ::buffa::DecodeError> {
54        let _ = depth;
55        #[allow(unused_variables)]
56        let view = self;
57        let mut cur: &'a [u8] = buf;
58        while !cur.is_empty() {
59            let before_tag = cur;
60            let tag = ::buffa::encoding::Tag::decode(&mut cur)?;
61            match tag.field_number() {
62                1u32 => {
63                    if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
64                        return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
65                            field_number: 1u32,
66                            expected: 2u8,
67                            actual: tag.wire_type() as u8,
68                        });
69                    }
70                    let entry_bytes = ::buffa::types::borrow_bytes(&mut cur)?;
71                    let mut entry_cur: &'a [u8] = entry_bytes;
72                    let mut key = "";
73                    let mut val = ::core::default::Default::default();
74                    while !entry_cur.is_empty() {
75                        let entry_tag = ::buffa::encoding::Tag::decode(&mut entry_cur)?;
76                        match entry_tag.field_number() {
77                            1 => {
78                                if entry_tag.wire_type()
79                                    != ::buffa::encoding::WireType::LengthDelimited
80                                {
81                                    return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
82                                        field_number: entry_tag.field_number(),
83                                        expected: 2u8,
84                                        actual: entry_tag.wire_type() as u8,
85                                    });
86                                }
87                                key = ::buffa::types::borrow_str(&mut entry_cur)?;
88                            }
89                            2 => {
90                                if entry_tag.wire_type()
91                                    != ::buffa::encoding::WireType::LengthDelimited
92                                {
93                                    return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
94                                        field_number: entry_tag.field_number(),
95                                        expected: 2u8,
96                                        actual: entry_tag.wire_type() as u8,
97                                    });
98                                }
99                                if depth == 0 {
100                                    return Err(::buffa::DecodeError::RecursionLimitExceeded);
101                                }
102                                let sub = ::buffa::types::borrow_bytes(&mut entry_cur)?;
103                                val = super::super::__buffa::view::ValueView::_decode_depth(
104                                    sub,
105                                    depth - 1,
106                                )?;
107                            }
108                            _ => {
109                                ::buffa::encoding::skip_field_depth(
110                                    entry_tag,
111                                    &mut entry_cur,
112                                    depth,
113                                )?;
114                            }
115                        }
116                    }
117                    view.fields.push(key, val);
118                }
119                _ => {
120                    ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?;
121                    let span_len = before_tag.len() - cur.len();
122                    view.__buffa_unknown_fields.push_raw(&before_tag[..span_len]);
123                }
124            }
125        }
126        ::core::result::Result::Ok(())
127    }
128}
129impl<'a> ::buffa::MessageView<'a> for StructView<'a> {
130    type Owned = super::super::Struct;
131    fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
132        Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT)
133    }
134    fn decode_view_with_limit(
135        buf: &'a [u8],
136        depth: u32,
137    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
138        Self::_decode_depth(buf, depth)
139    }
140    fn to_owned_message(&self) -> super::super::Struct {
141        self.to_owned_from_source(None)
142    }
143    #[allow(clippy::useless_conversion, clippy::needless_update)]
144    fn to_owned_from_source(
145        &self,
146        __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>,
147    ) -> super::super::Struct {
148        #[allow(unused_imports)]
149        use ::buffa::alloc::string::ToString as _;
150        let _ = __buffa_src;
151        super::super::Struct {
152            fields: self
153                .fields
154                .iter()
155                .map(|(k, v)| (k.to_string(), v.to_owned_from_source(__buffa_src)))
156                .collect(),
157            __buffa_unknown_fields: self
158                .__buffa_unknown_fields
159                .to_owned()
160                .unwrap_or_default()
161                .into(),
162            ..::core::default::Default::default()
163        }
164    }
165}
166impl<'a> ::buffa::ViewEncode<'a> for StructView<'a> {
167    #[allow(clippy::needless_borrow, clippy::let_and_return)]
168    fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 {
169        #[allow(unused_imports)]
170        use ::buffa::Enumeration as _;
171        let mut size = 0u32;
172        #[allow(clippy::for_kv_map)]
173        for (k, v) in &self.fields {
174            let entry_size: u32 = 1u32 + ::buffa::types::string_encoded_len(k) as u32
175                + 1u32
176                + {
177                    let __slot = __cache.reserve();
178                    let inner = v.compute_size(__cache);
179                    __cache.set(__slot, inner);
180                    ::buffa::encoding::varint_len(inner as u64) as u32 + inner
181                };
182            size
183                += 1u32 + ::buffa::encoding::varint_len(entry_size as u64) as u32
184                    + entry_size;
185        }
186        size += self.__buffa_unknown_fields.encoded_len() as u32;
187        size
188    }
189    #[allow(clippy::needless_borrow)]
190    fn write_to(
191        &self,
192        __cache: &mut ::buffa::SizeCache,
193        buf: &mut impl ::buffa::bytes::BufMut,
194    ) {
195        #[allow(unused_imports)]
196        use ::buffa::Enumeration as _;
197        for (k, v) in &self.fields {
198            let __v_len = __cache.consume_next();
199            let entry_size: u32 = 1u32 + ::buffa::types::string_encoded_len(k) as u32
200                + 1u32
201                + (::buffa::encoding::varint_len(__v_len as u64) as u32 + __v_len);
202            ::buffa::encoding::Tag::new(
203                    1u32,
204                    ::buffa::encoding::WireType::LengthDelimited,
205                )
206                .encode(buf);
207            ::buffa::encoding::encode_varint(entry_size as u64, buf);
208            ::buffa::encoding::Tag::new(
209                    1u32,
210                    ::buffa::encoding::WireType::LengthDelimited,
211                )
212                .encode(buf);
213            ::buffa::types::encode_string(k, buf);
214            ::buffa::encoding::Tag::new(
215                    2u32,
216                    ::buffa::encoding::WireType::LengthDelimited,
217                )
218                .encode(buf);
219            ::buffa::encoding::encode_varint(__v_len as u64, buf);
220            v.write_to(__cache, buf);
221        }
222        self.__buffa_unknown_fields.write_to(buf);
223    }
224}
225impl<'a> ::buffa::MessageName for StructView<'a> {
226    const PACKAGE: &'static str = "google.protobuf";
227    const NAME: &'static str = "Struct";
228    const FULL_NAME: &'static str = "google.protobuf.Struct";
229    const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.Struct";
230}
231impl<'v> ::buffa::DefaultViewInstance for StructView<'v> {
232    fn default_view_instance<'a>() -> &'a Self
233    where
234        Self: 'a,
235    {
236        static VALUE: ::buffa::__private::OnceBox<StructView<'static>> = ::buffa::__private::OnceBox::new();
237        VALUE
238            .get_or_init(|| ::buffa::alloc::boxed::Box::new(
239                <StructView<'static>>::default(),
240            ))
241    }
242}
243impl ::buffa::ViewReborrow for StructView<'static> {
244    type Reborrowed<'b> = StructView<'b>;
245    fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> {
246        this
247    }
248}
249/// `Value` represents a dynamically typed value which can be either
250/// null, a number, a string, a boolean, a recursive struct value, or a
251/// list of values. A producer of value is expected to set one of these
252/// variants. Absence of any variant indicates an error.
253///
254/// The JSON representation for `Value` is JSON value.
255#[derive(Clone, Debug, Default)]
256pub struct ValueView<'a> {
257    pub kind: ::core::option::Option<
258        super::super::__buffa::view::oneof::value::Kind<'a>,
259    >,
260    pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
261}
262impl<'a> ValueView<'a> {
263    /// Decode from `buf`, enforcing a recursion depth limit for nested messages.
264    ///
265    /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`]
266    /// and by generated sub-message decode arms with `depth - 1`.
267    ///
268    /// **Not part of the public API.** Named with a leading underscore to
269    /// signal that it is for generated-code use only.
270    #[doc(hidden)]
271    pub fn _decode_depth(
272        buf: &'a [u8],
273        depth: u32,
274    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
275        let mut view = Self::default();
276        view._merge_into_view(buf, depth)?;
277        ::core::result::Result::Ok(view)
278    }
279    /// Merge fields from `buf` into this view (proto merge semantics).
280    ///
281    /// Repeated fields append; singular fields last-wins; singular
282    /// MESSAGE fields merge recursively. Used by sub-message decode
283    /// arms when the same field appears multiple times on the wire.
284    ///
285    /// **Not part of the public API.**
286    #[doc(hidden)]
287    pub fn _merge_into_view(
288        &mut self,
289        buf: &'a [u8],
290        depth: u32,
291    ) -> ::core::result::Result<(), ::buffa::DecodeError> {
292        let _ = depth;
293        #[allow(unused_variables)]
294        let view = self;
295        let mut cur: &'a [u8] = buf;
296        while !cur.is_empty() {
297            let before_tag = cur;
298            let tag = ::buffa::encoding::Tag::decode(&mut cur)?;
299            match tag.field_number() {
300                1u32 => {
301                    if tag.wire_type() != ::buffa::encoding::WireType::Varint {
302                        return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
303                            field_number: 1u32,
304                            expected: 0u8,
305                            actual: tag.wire_type() as u8,
306                        });
307                    }
308                    view.kind = Some(
309                        super::super::__buffa::view::oneof::value::Kind::NullValue(
310                            ::buffa::EnumValue::from(
311                                ::buffa::types::decode_int32(&mut cur)?,
312                            ),
313                        ),
314                    );
315                }
316                2u32 => {
317                    if tag.wire_type() != ::buffa::encoding::WireType::Fixed64 {
318                        return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
319                            field_number: 2u32,
320                            expected: 1u8,
321                            actual: tag.wire_type() as u8,
322                        });
323                    }
324                    view.kind = Some(
325                        super::super::__buffa::view::oneof::value::Kind::NumberValue(
326                            ::buffa::types::decode_double(&mut cur)?,
327                        ),
328                    );
329                }
330                3u32 => {
331                    if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
332                        return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
333                            field_number: 3u32,
334                            expected: 2u8,
335                            actual: tag.wire_type() as u8,
336                        });
337                    }
338                    view.kind = Some(
339                        super::super::__buffa::view::oneof::value::Kind::StringValue(
340                            ::buffa::types::borrow_str(&mut cur)?,
341                        ),
342                    );
343                }
344                4u32 => {
345                    if tag.wire_type() != ::buffa::encoding::WireType::Varint {
346                        return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
347                            field_number: 4u32,
348                            expected: 0u8,
349                            actual: tag.wire_type() as u8,
350                        });
351                    }
352                    view.kind = Some(
353                        super::super::__buffa::view::oneof::value::Kind::BoolValue(
354                            ::buffa::types::decode_bool(&mut cur)?,
355                        ),
356                    );
357                }
358                5u32 => {
359                    if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
360                        return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
361                            field_number: 5u32,
362                            expected: 2u8,
363                            actual: tag.wire_type() as u8,
364                        });
365                    }
366                    if depth == 0 {
367                        return Err(::buffa::DecodeError::RecursionLimitExceeded);
368                    }
369                    let sub = ::buffa::types::borrow_bytes(&mut cur)?;
370                    if let Some(
371                        super::super::__buffa::view::oneof::value::Kind::StructValue(
372                            ref mut existing,
373                        ),
374                    ) = view.kind
375                    {
376                        existing._merge_into_view(sub, depth - 1)?;
377                    } else {
378                        view.kind = Some(
379                            super::super::__buffa::view::oneof::value::Kind::StructValue(
380                                ::buffa::alloc::boxed::Box::new(
381                                    super::super::__buffa::view::StructView::_decode_depth(
382                                        sub,
383                                        depth - 1,
384                                    )?,
385                                ),
386                            ),
387                        );
388                    }
389                }
390                6u32 => {
391                    if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
392                        return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
393                            field_number: 6u32,
394                            expected: 2u8,
395                            actual: tag.wire_type() as u8,
396                        });
397                    }
398                    if depth == 0 {
399                        return Err(::buffa::DecodeError::RecursionLimitExceeded);
400                    }
401                    let sub = ::buffa::types::borrow_bytes(&mut cur)?;
402                    if let Some(
403                        super::super::__buffa::view::oneof::value::Kind::ListValue(
404                            ref mut existing,
405                        ),
406                    ) = view.kind
407                    {
408                        existing._merge_into_view(sub, depth - 1)?;
409                    } else {
410                        view.kind = Some(
411                            super::super::__buffa::view::oneof::value::Kind::ListValue(
412                                ::buffa::alloc::boxed::Box::new(
413                                    super::super::__buffa::view::ListValueView::_decode_depth(
414                                        sub,
415                                        depth - 1,
416                                    )?,
417                                ),
418                            ),
419                        );
420                    }
421                }
422                _ => {
423                    ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?;
424                    let span_len = before_tag.len() - cur.len();
425                    view.__buffa_unknown_fields.push_raw(&before_tag[..span_len]);
426                }
427            }
428        }
429        ::core::result::Result::Ok(())
430    }
431}
432impl<'a> ::buffa::MessageView<'a> for ValueView<'a> {
433    type Owned = super::super::Value;
434    fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
435        Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT)
436    }
437    fn decode_view_with_limit(
438        buf: &'a [u8],
439        depth: u32,
440    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
441        Self::_decode_depth(buf, depth)
442    }
443    fn to_owned_message(&self) -> super::super::Value {
444        self.to_owned_from_source(None)
445    }
446    #[allow(clippy::useless_conversion, clippy::needless_update)]
447    fn to_owned_from_source(
448        &self,
449        __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>,
450    ) -> super::super::Value {
451        #[allow(unused_imports)]
452        use ::buffa::alloc::string::ToString as _;
453        let _ = __buffa_src;
454        super::super::Value {
455            kind: self
456                .kind
457                .as_ref()
458                .map(|v| match v {
459                    super::super::__buffa::view::oneof::value::Kind::NullValue(v) => {
460                        super::super::__buffa::oneof::value::Kind::NullValue(*v)
461                    }
462                    super::super::__buffa::view::oneof::value::Kind::NumberValue(v) => {
463                        super::super::__buffa::oneof::value::Kind::NumberValue(*v)
464                    }
465                    super::super::__buffa::view::oneof::value::Kind::StringValue(v) => {
466                        super::super::__buffa::oneof::value::Kind::StringValue(
467                            v.to_string(),
468                        )
469                    }
470                    super::super::__buffa::view::oneof::value::Kind::BoolValue(v) => {
471                        super::super::__buffa::oneof::value::Kind::BoolValue(*v)
472                    }
473                    super::super::__buffa::view::oneof::value::Kind::StructValue(v) => {
474                        super::super::__buffa::oneof::value::Kind::StructValue(
475                            ::buffa::alloc::boxed::Box::new(
476                                v.to_owned_from_source(__buffa_src),
477                            ),
478                        )
479                    }
480                    super::super::__buffa::view::oneof::value::Kind::ListValue(v) => {
481                        super::super::__buffa::oneof::value::Kind::ListValue(
482                            ::buffa::alloc::boxed::Box::new(
483                                v.to_owned_from_source(__buffa_src),
484                            ),
485                        )
486                    }
487                }),
488            __buffa_unknown_fields: self
489                .__buffa_unknown_fields
490                .to_owned()
491                .unwrap_or_default()
492                .into(),
493            ..::core::default::Default::default()
494        }
495    }
496}
497impl<'a> ::buffa::ViewEncode<'a> for ValueView<'a> {
498    #[allow(clippy::needless_borrow, clippy::let_and_return)]
499    fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 {
500        #[allow(unused_imports)]
501        use ::buffa::Enumeration as _;
502        let mut size = 0u32;
503        if let ::core::option::Option::Some(ref v) = self.kind {
504            match v {
505                super::super::__buffa::view::oneof::value::Kind::NullValue(x) => {
506                    size += 1u32 + ::buffa::types::int32_encoded_len(x.to_i32()) as u32;
507                }
508                super::super::__buffa::view::oneof::value::Kind::NumberValue(_x) => {
509                    size += 1u32 + ::buffa::types::FIXED64_ENCODED_LEN as u32;
510                }
511                super::super::__buffa::view::oneof::value::Kind::StringValue(x) => {
512                    size += 1u32 + ::buffa::types::string_encoded_len(x) as u32;
513                }
514                super::super::__buffa::view::oneof::value::Kind::BoolValue(_x) => {
515                    size += 1u32 + ::buffa::types::BOOL_ENCODED_LEN as u32;
516                }
517                super::super::__buffa::view::oneof::value::Kind::StructValue(x) => {
518                    let __slot = __cache.reserve();
519                    let inner = x.compute_size(__cache);
520                    __cache.set(__slot, inner);
521                    size
522                        += 1u32 + ::buffa::encoding::varint_len(inner as u64) as u32
523                            + inner;
524                }
525                super::super::__buffa::view::oneof::value::Kind::ListValue(x) => {
526                    let __slot = __cache.reserve();
527                    let inner = x.compute_size(__cache);
528                    __cache.set(__slot, inner);
529                    size
530                        += 1u32 + ::buffa::encoding::varint_len(inner as u64) as u32
531                            + inner;
532                }
533            }
534        }
535        size += self.__buffa_unknown_fields.encoded_len() as u32;
536        size
537    }
538    #[allow(clippy::needless_borrow)]
539    fn write_to(
540        &self,
541        __cache: &mut ::buffa::SizeCache,
542        buf: &mut impl ::buffa::bytes::BufMut,
543    ) {
544        #[allow(unused_imports)]
545        use ::buffa::Enumeration as _;
546        if let ::core::option::Option::Some(ref v) = self.kind {
547            match v {
548                super::super::__buffa::view::oneof::value::Kind::NullValue(x) => {
549                    ::buffa::encoding::Tag::new(
550                            1u32,
551                            ::buffa::encoding::WireType::Varint,
552                        )
553                        .encode(buf);
554                    ::buffa::types::encode_int32(x.to_i32(), buf);
555                }
556                super::super::__buffa::view::oneof::value::Kind::NumberValue(x) => {
557                    ::buffa::encoding::Tag::new(
558                            2u32,
559                            ::buffa::encoding::WireType::Fixed64,
560                        )
561                        .encode(buf);
562                    ::buffa::types::encode_double(*x, buf);
563                }
564                super::super::__buffa::view::oneof::value::Kind::StringValue(x) => {
565                    ::buffa::encoding::Tag::new(
566                            3u32,
567                            ::buffa::encoding::WireType::LengthDelimited,
568                        )
569                        .encode(buf);
570                    ::buffa::types::encode_string(x, buf);
571                }
572                super::super::__buffa::view::oneof::value::Kind::BoolValue(x) => {
573                    ::buffa::encoding::Tag::new(
574                            4u32,
575                            ::buffa::encoding::WireType::Varint,
576                        )
577                        .encode(buf);
578                    ::buffa::types::encode_bool(*x, buf);
579                }
580                super::super::__buffa::view::oneof::value::Kind::StructValue(x) => {
581                    ::buffa::encoding::Tag::new(
582                            5u32,
583                            ::buffa::encoding::WireType::LengthDelimited,
584                        )
585                        .encode(buf);
586                    ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf);
587                    x.write_to(__cache, buf);
588                }
589                super::super::__buffa::view::oneof::value::Kind::ListValue(x) => {
590                    ::buffa::encoding::Tag::new(
591                            6u32,
592                            ::buffa::encoding::WireType::LengthDelimited,
593                        )
594                        .encode(buf);
595                    ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf);
596                    x.write_to(__cache, buf);
597                }
598            }
599        }
600        self.__buffa_unknown_fields.write_to(buf);
601    }
602}
603impl<'a> ::buffa::MessageName for ValueView<'a> {
604    const PACKAGE: &'static str = "google.protobuf";
605    const NAME: &'static str = "Value";
606    const FULL_NAME: &'static str = "google.protobuf.Value";
607    const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.Value";
608}
609impl<'v> ::buffa::DefaultViewInstance for ValueView<'v> {
610    fn default_view_instance<'a>() -> &'a Self
611    where
612        Self: 'a,
613    {
614        static VALUE: ::buffa::__private::OnceBox<ValueView<'static>> = ::buffa::__private::OnceBox::new();
615        VALUE
616            .get_or_init(|| ::buffa::alloc::boxed::Box::new(
617                <ValueView<'static>>::default(),
618            ))
619    }
620}
621impl ::buffa::ViewReborrow for ValueView<'static> {
622    type Reborrowed<'b> = ValueView<'b>;
623    fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> {
624        this
625    }
626}
627/// `ListValue` is a wrapper around a repeated field of values.
628///
629/// The JSON representation for `ListValue` is JSON array.
630#[derive(Clone, Debug, Default)]
631pub struct ListValueView<'a> {
632    /// Repeated field of dynamically typed values.
633    ///
634    /// Field 1: `values`
635    pub values: ::buffa::RepeatedView<'a, super::super::__buffa::view::ValueView<'a>>,
636    pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
637}
638impl<'a> ListValueView<'a> {
639    /// Decode from `buf`, enforcing a recursion depth limit for nested messages.
640    ///
641    /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`]
642    /// and by generated sub-message decode arms with `depth - 1`.
643    ///
644    /// **Not part of the public API.** Named with a leading underscore to
645    /// signal that it is for generated-code use only.
646    #[doc(hidden)]
647    pub fn _decode_depth(
648        buf: &'a [u8],
649        depth: u32,
650    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
651        let mut view = Self::default();
652        view._merge_into_view(buf, depth)?;
653        ::core::result::Result::Ok(view)
654    }
655    /// Merge fields from `buf` into this view (proto merge semantics).
656    ///
657    /// Repeated fields append; singular fields last-wins; singular
658    /// MESSAGE fields merge recursively. Used by sub-message decode
659    /// arms when the same field appears multiple times on the wire.
660    ///
661    /// **Not part of the public API.**
662    #[doc(hidden)]
663    pub fn _merge_into_view(
664        &mut self,
665        buf: &'a [u8],
666        depth: u32,
667    ) -> ::core::result::Result<(), ::buffa::DecodeError> {
668        let _ = depth;
669        #[allow(unused_variables)]
670        let view = self;
671        let mut cur: &'a [u8] = buf;
672        while !cur.is_empty() {
673            let before_tag = cur;
674            let tag = ::buffa::encoding::Tag::decode(&mut cur)?;
675            match tag.field_number() {
676                1u32 => {
677                    if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
678                        return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
679                            field_number: 1u32,
680                            expected: 2u8,
681                            actual: tag.wire_type() as u8,
682                        });
683                    }
684                    if depth == 0 {
685                        return Err(::buffa::DecodeError::RecursionLimitExceeded);
686                    }
687                    let sub = ::buffa::types::borrow_bytes(&mut cur)?;
688                    view.values
689                        .push(
690                            super::super::__buffa::view::ValueView::_decode_depth(
691                                sub,
692                                depth - 1,
693                            )?,
694                        );
695                }
696                _ => {
697                    ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?;
698                    let span_len = before_tag.len() - cur.len();
699                    view.__buffa_unknown_fields.push_raw(&before_tag[..span_len]);
700                }
701            }
702        }
703        ::core::result::Result::Ok(())
704    }
705}
706impl<'a> ::buffa::MessageView<'a> for ListValueView<'a> {
707    type Owned = super::super::ListValue;
708    fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
709        Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT)
710    }
711    fn decode_view_with_limit(
712        buf: &'a [u8],
713        depth: u32,
714    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
715        Self::_decode_depth(buf, depth)
716    }
717    fn to_owned_message(&self) -> super::super::ListValue {
718        self.to_owned_from_source(None)
719    }
720    #[allow(clippy::useless_conversion, clippy::needless_update)]
721    fn to_owned_from_source(
722        &self,
723        __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>,
724    ) -> super::super::ListValue {
725        #[allow(unused_imports)]
726        use ::buffa::alloc::string::ToString as _;
727        let _ = __buffa_src;
728        super::super::ListValue {
729            values: self
730                .values
731                .iter()
732                .map(|v| v.to_owned_from_source(__buffa_src))
733                .collect(),
734            __buffa_unknown_fields: self
735                .__buffa_unknown_fields
736                .to_owned()
737                .unwrap_or_default()
738                .into(),
739            ..::core::default::Default::default()
740        }
741    }
742}
743impl<'a> ::buffa::ViewEncode<'a> for ListValueView<'a> {
744    #[allow(clippy::needless_borrow, clippy::let_and_return)]
745    fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 {
746        #[allow(unused_imports)]
747        use ::buffa::Enumeration as _;
748        let mut size = 0u32;
749        for v in &self.values {
750            let __slot = __cache.reserve();
751            let inner_size = v.compute_size(__cache);
752            __cache.set(__slot, inner_size);
753            size
754                += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
755                    + inner_size;
756        }
757        size += self.__buffa_unknown_fields.encoded_len() as u32;
758        size
759    }
760    #[allow(clippy::needless_borrow)]
761    fn write_to(
762        &self,
763        __cache: &mut ::buffa::SizeCache,
764        buf: &mut impl ::buffa::bytes::BufMut,
765    ) {
766        #[allow(unused_imports)]
767        use ::buffa::Enumeration as _;
768        for v in &self.values {
769            ::buffa::encoding::Tag::new(
770                    1u32,
771                    ::buffa::encoding::WireType::LengthDelimited,
772                )
773                .encode(buf);
774            ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf);
775            v.write_to(__cache, buf);
776        }
777        self.__buffa_unknown_fields.write_to(buf);
778    }
779}
780impl<'a> ::buffa::MessageName for ListValueView<'a> {
781    const PACKAGE: &'static str = "google.protobuf";
782    const NAME: &'static str = "ListValue";
783    const FULL_NAME: &'static str = "google.protobuf.ListValue";
784    const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.ListValue";
785}
786impl<'v> ::buffa::DefaultViewInstance for ListValueView<'v> {
787    fn default_view_instance<'a>() -> &'a Self
788    where
789        Self: 'a,
790    {
791        static VALUE: ::buffa::__private::OnceBox<ListValueView<'static>> = ::buffa::__private::OnceBox::new();
792        VALUE
793            .get_or_init(|| ::buffa::alloc::boxed::Box::new(
794                <ListValueView<'static>>::default(),
795            ))
796    }
797}
798impl ::buffa::ViewReborrow for ListValueView<'static> {
799    type Reborrowed<'b> = ListValueView<'b>;
800    fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> {
801        this
802    }
803}