buffa-types 0.4.0

Protobuf well-known types for buffa
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
// @generated by buffa-codegen. DO NOT EDIT.
// source: google/protobuf/struct.proto

/// `Struct` represents a structured data value, consisting of fields
/// which map to dynamically typed values. In some languages, `Struct`
/// might be supported by a native representation. For example, in
/// scripting languages like JS a struct is represented as an
/// object. The details of that representation are described together
/// with the proto support for the language.
///
/// The JSON representation for `Struct` is JSON object.
#[derive(Clone, Debug, Default)]
pub struct StructView<'a> {
    /// Unordered map of dynamically typed values.
    ///
    /// Field 1: `fields` (map)
    pub fields: ::buffa::MapView<
        'a,
        &'a str,
        super::super::__buffa::view::ValueView<'a>,
    >,
    pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
}
impl<'a> StructView<'a> {
    /// Decode from `buf`, enforcing a recursion depth limit for nested messages.
    ///
    /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`]
    /// and by generated sub-message decode arms with `depth - 1`.
    ///
    /// **Not part of the public API.** Named with a leading underscore to
    /// signal that it is for generated-code use only.
    #[doc(hidden)]
    pub fn _decode_depth(
        buf: &'a [u8],
        depth: u32,
    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
        let mut view = Self::default();
        view._merge_into_view(buf, depth)?;
        ::core::result::Result::Ok(view)
    }
    /// Merge fields from `buf` into this view (proto merge semantics).
    ///
    /// Repeated fields append; singular fields last-wins; singular
    /// MESSAGE fields merge recursively. Used by sub-message decode
    /// arms when the same field appears multiple times on the wire.
    ///
    /// **Not part of the public API.**
    #[doc(hidden)]
    pub fn _merge_into_view(
        &mut self,
        buf: &'a [u8],
        depth: u32,
    ) -> ::core::result::Result<(), ::buffa::DecodeError> {
        let _ = depth;
        #[allow(unused_variables)]
        let view = self;
        let mut cur: &'a [u8] = buf;
        while !cur.is_empty() {
            let before_tag = cur;
            let tag = ::buffa::encoding::Tag::decode(&mut cur)?;
            match tag.field_number() {
                1u32 => {
                    if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
                        return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
                            field_number: 1u32,
                            expected: 2u8,
                            actual: tag.wire_type() as u8,
                        });
                    }
                    let entry_bytes = ::buffa::types::borrow_bytes(&mut cur)?;
                    let mut entry_cur: &'a [u8] = entry_bytes;
                    let mut key = "";
                    let mut val = ::core::default::Default::default();
                    while !entry_cur.is_empty() {
                        let entry_tag = ::buffa::encoding::Tag::decode(&mut entry_cur)?;
                        match entry_tag.field_number() {
                            1 => {
                                if entry_tag.wire_type()
                                    != ::buffa::encoding::WireType::LengthDelimited
                                {
                                    return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
                                        field_number: entry_tag.field_number(),
                                        expected: 2u8,
                                        actual: entry_tag.wire_type() as u8,
                                    });
                                }
                                key = ::buffa::types::borrow_str(&mut entry_cur)?;
                            }
                            2 => {
                                if entry_tag.wire_type()
                                    != ::buffa::encoding::WireType::LengthDelimited
                                {
                                    return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
                                        field_number: entry_tag.field_number(),
                                        expected: 2u8,
                                        actual: entry_tag.wire_type() as u8,
                                    });
                                }
                                if depth == 0 {
                                    return Err(::buffa::DecodeError::RecursionLimitExceeded);
                                }
                                let sub = ::buffa::types::borrow_bytes(&mut entry_cur)?;
                                val = super::super::__buffa::view::ValueView::_decode_depth(
                                    sub,
                                    depth - 1,
                                )?;
                            }
                            _ => {
                                ::buffa::encoding::skip_field_depth(
                                    entry_tag,
                                    &mut entry_cur,
                                    depth,
                                )?;
                            }
                        }
                    }
                    view.fields.push(key, val);
                }
                _ => {
                    ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?;
                    let span_len = before_tag.len() - cur.len();
                    view.__buffa_unknown_fields.push_raw(&before_tag[..span_len]);
                }
            }
        }
        ::core::result::Result::Ok(())
    }
}
impl<'a> ::buffa::MessageView<'a> for StructView<'a> {
    type Owned = super::super::Struct;
    fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
        Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT)
    }
    fn decode_view_with_limit(
        buf: &'a [u8],
        depth: u32,
    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
        Self::_decode_depth(buf, depth)
    }
    /// Convert this view to the owned message type.
    #[allow(clippy::redundant_closure, clippy::useless_conversion)]
    #[allow(clippy::needless_update)]
    fn to_owned_message(&self) -> super::super::Struct {
        #[allow(unused_imports)]
        use ::buffa::alloc::string::ToString as _;
        super::super::Struct {
            fields: self
                .fields
                .iter()
                .map(|(k, v)| (k.to_string(), v.to_owned_message()))
                .collect(),
            __buffa_unknown_fields: self
                .__buffa_unknown_fields
                .to_owned()
                .unwrap_or_default()
                .into(),
            ..::core::default::Default::default()
        }
    }
}
impl<'a> ::buffa::ViewEncode<'a> for StructView<'a> {
    #[allow(clippy::needless_borrow, clippy::let_and_return)]
    fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 {
        #[allow(unused_imports)]
        use ::buffa::Enumeration as _;
        let mut size = 0u32;
        #[allow(clippy::for_kv_map)]
        for (k, v) in &self.fields {
            let entry_size: u32 = 1u32 + ::buffa::types::string_encoded_len(k) as u32
                + 1u32
                + {
                    let __slot = __cache.reserve();
                    let inner = v.compute_size(__cache);
                    __cache.set(__slot, inner);
                    ::buffa::encoding::varint_len(inner as u64) as u32 + inner
                };
            size
                += 1u32 + ::buffa::encoding::varint_len(entry_size as u64) as u32
                    + entry_size;
        }
        size += self.__buffa_unknown_fields.encoded_len() as u32;
        size
    }
    #[allow(clippy::needless_borrow)]
    fn write_to(
        &self,
        __cache: &mut ::buffa::SizeCache,
        buf: &mut impl ::buffa::bytes::BufMut,
    ) {
        #[allow(unused_imports)]
        use ::buffa::Enumeration as _;
        for (k, v) in &self.fields {
            let __v_len = __cache.consume_next();
            let entry_size: u32 = 1u32 + ::buffa::types::string_encoded_len(k) as u32
                + 1u32
                + (::buffa::encoding::varint_len(__v_len as u64) as u32 + __v_len);
            ::buffa::encoding::Tag::new(
                    1u32,
                    ::buffa::encoding::WireType::LengthDelimited,
                )
                .encode(buf);
            ::buffa::encoding::encode_varint(entry_size as u64, buf);
            ::buffa::encoding::Tag::new(
                    1u32,
                    ::buffa::encoding::WireType::LengthDelimited,
                )
                .encode(buf);
            ::buffa::types::encode_string(k, buf);
            ::buffa::encoding::Tag::new(
                    2u32,
                    ::buffa::encoding::WireType::LengthDelimited,
                )
                .encode(buf);
            ::buffa::encoding::encode_varint(__v_len as u64, buf);
            v.write_to(__cache, buf);
        }
        self.__buffa_unknown_fields.write_to(buf);
    }
}
impl<'v> ::buffa::DefaultViewInstance for StructView<'v> {
    fn default_view_instance<'a>() -> &'a Self
    where
        Self: 'a,
    {
        static VALUE: ::buffa::__private::OnceBox<StructView<'static>> = ::buffa::__private::OnceBox::new();
        VALUE
            .get_or_init(|| ::buffa::alloc::boxed::Box::new(
                <StructView<'static>>::default(),
            ))
    }
}
/// `Value` represents a dynamically typed value which can be either
/// null, a number, a string, a boolean, a recursive struct value, or a
/// list of values. A producer of value is expected to set one of these
/// variants. Absence of any variant indicates an error.
///
/// The JSON representation for `Value` is JSON value.
#[derive(Clone, Debug, Default)]
pub struct ValueView<'a> {
    pub kind: ::core::option::Option<
        super::super::__buffa::view::oneof::value::Kind<'a>,
    >,
    pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
}
impl<'a> ValueView<'a> {
    /// Decode from `buf`, enforcing a recursion depth limit for nested messages.
    ///
    /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`]
    /// and by generated sub-message decode arms with `depth - 1`.
    ///
    /// **Not part of the public API.** Named with a leading underscore to
    /// signal that it is for generated-code use only.
    #[doc(hidden)]
    pub fn _decode_depth(
        buf: &'a [u8],
        depth: u32,
    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
        let mut view = Self::default();
        view._merge_into_view(buf, depth)?;
        ::core::result::Result::Ok(view)
    }
    /// Merge fields from `buf` into this view (proto merge semantics).
    ///
    /// Repeated fields append; singular fields last-wins; singular
    /// MESSAGE fields merge recursively. Used by sub-message decode
    /// arms when the same field appears multiple times on the wire.
    ///
    /// **Not part of the public API.**
    #[doc(hidden)]
    pub fn _merge_into_view(
        &mut self,
        buf: &'a [u8],
        depth: u32,
    ) -> ::core::result::Result<(), ::buffa::DecodeError> {
        let _ = depth;
        #[allow(unused_variables)]
        let view = self;
        let mut cur: &'a [u8] = buf;
        while !cur.is_empty() {
            let before_tag = cur;
            let tag = ::buffa::encoding::Tag::decode(&mut cur)?;
            match tag.field_number() {
                1u32 => {
                    if tag.wire_type() != ::buffa::encoding::WireType::Varint {
                        return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
                            field_number: 1u32,
                            expected: 0u8,
                            actual: tag.wire_type() as u8,
                        });
                    }
                    view.kind = Some(
                        super::super::__buffa::view::oneof::value::Kind::NullValue(
                            ::buffa::EnumValue::from(
                                ::buffa::types::decode_int32(&mut cur)?,
                            ),
                        ),
                    );
                }
                2u32 => {
                    if tag.wire_type() != ::buffa::encoding::WireType::Fixed64 {
                        return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
                            field_number: 2u32,
                            expected: 1u8,
                            actual: tag.wire_type() as u8,
                        });
                    }
                    view.kind = Some(
                        super::super::__buffa::view::oneof::value::Kind::NumberValue(
                            ::buffa::types::decode_double(&mut cur)?,
                        ),
                    );
                }
                3u32 => {
                    if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
                        return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
                            field_number: 3u32,
                            expected: 2u8,
                            actual: tag.wire_type() as u8,
                        });
                    }
                    view.kind = Some(
                        super::super::__buffa::view::oneof::value::Kind::StringValue(
                            ::buffa::types::borrow_str(&mut cur)?,
                        ),
                    );
                }
                4u32 => {
                    if tag.wire_type() != ::buffa::encoding::WireType::Varint {
                        return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
                            field_number: 4u32,
                            expected: 0u8,
                            actual: tag.wire_type() as u8,
                        });
                    }
                    view.kind = Some(
                        super::super::__buffa::view::oneof::value::Kind::BoolValue(
                            ::buffa::types::decode_bool(&mut cur)?,
                        ),
                    );
                }
                5u32 => {
                    if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
                        return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
                            field_number: 5u32,
                            expected: 2u8,
                            actual: tag.wire_type() as u8,
                        });
                    }
                    if depth == 0 {
                        return Err(::buffa::DecodeError::RecursionLimitExceeded);
                    }
                    let sub = ::buffa::types::borrow_bytes(&mut cur)?;
                    if let Some(
                        super::super::__buffa::view::oneof::value::Kind::StructValue(
                            ref mut existing,
                        ),
                    ) = view.kind
                    {
                        existing._merge_into_view(sub, depth - 1)?;
                    } else {
                        view.kind = Some(
                            super::super::__buffa::view::oneof::value::Kind::StructValue(
                                ::buffa::alloc::boxed::Box::new(
                                    super::super::__buffa::view::StructView::_decode_depth(
                                        sub,
                                        depth - 1,
                                    )?,
                                ),
                            ),
                        );
                    }
                }
                6u32 => {
                    if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
                        return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
                            field_number: 6u32,
                            expected: 2u8,
                            actual: tag.wire_type() as u8,
                        });
                    }
                    if depth == 0 {
                        return Err(::buffa::DecodeError::RecursionLimitExceeded);
                    }
                    let sub = ::buffa::types::borrow_bytes(&mut cur)?;
                    if let Some(
                        super::super::__buffa::view::oneof::value::Kind::ListValue(
                            ref mut existing,
                        ),
                    ) = view.kind
                    {
                        existing._merge_into_view(sub, depth - 1)?;
                    } else {
                        view.kind = Some(
                            super::super::__buffa::view::oneof::value::Kind::ListValue(
                                ::buffa::alloc::boxed::Box::new(
                                    super::super::__buffa::view::ListValueView::_decode_depth(
                                        sub,
                                        depth - 1,
                                    )?,
                                ),
                            ),
                        );
                    }
                }
                _ => {
                    ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?;
                    let span_len = before_tag.len() - cur.len();
                    view.__buffa_unknown_fields.push_raw(&before_tag[..span_len]);
                }
            }
        }
        ::core::result::Result::Ok(())
    }
}
impl<'a> ::buffa::MessageView<'a> for ValueView<'a> {
    type Owned = super::super::Value;
    fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
        Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT)
    }
    fn decode_view_with_limit(
        buf: &'a [u8],
        depth: u32,
    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
        Self::_decode_depth(buf, depth)
    }
    /// Convert this view to the owned message type.
    #[allow(clippy::redundant_closure, clippy::useless_conversion)]
    #[allow(clippy::needless_update)]
    fn to_owned_message(&self) -> super::super::Value {
        #[allow(unused_imports)]
        use ::buffa::alloc::string::ToString as _;
        super::super::Value {
            kind: self
                .kind
                .as_ref()
                .map(|v| match v {
                    super::super::__buffa::view::oneof::value::Kind::NullValue(v) => {
                        super::super::__buffa::oneof::value::Kind::NullValue(*v)
                    }
                    super::super::__buffa::view::oneof::value::Kind::NumberValue(v) => {
                        super::super::__buffa::oneof::value::Kind::NumberValue(*v)
                    }
                    super::super::__buffa::view::oneof::value::Kind::StringValue(v) => {
                        super::super::__buffa::oneof::value::Kind::StringValue(
                            v.to_string(),
                        )
                    }
                    super::super::__buffa::view::oneof::value::Kind::BoolValue(v) => {
                        super::super::__buffa::oneof::value::Kind::BoolValue(*v)
                    }
                    super::super::__buffa::view::oneof::value::Kind::StructValue(v) => {
                        super::super::__buffa::oneof::value::Kind::StructValue(
                            ::buffa::alloc::boxed::Box::new(v.to_owned_message()),
                        )
                    }
                    super::super::__buffa::view::oneof::value::Kind::ListValue(v) => {
                        super::super::__buffa::oneof::value::Kind::ListValue(
                            ::buffa::alloc::boxed::Box::new(v.to_owned_message()),
                        )
                    }
                }),
            __buffa_unknown_fields: self
                .__buffa_unknown_fields
                .to_owned()
                .unwrap_or_default()
                .into(),
            ..::core::default::Default::default()
        }
    }
}
impl<'a> ::buffa::ViewEncode<'a> for ValueView<'a> {
    #[allow(clippy::needless_borrow, clippy::let_and_return)]
    fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 {
        #[allow(unused_imports)]
        use ::buffa::Enumeration as _;
        let mut size = 0u32;
        if let ::core::option::Option::Some(ref v) = self.kind {
            match v {
                super::super::__buffa::view::oneof::value::Kind::NullValue(x) => {
                    size += 1u32 + ::buffa::types::int32_encoded_len(x.to_i32()) as u32;
                }
                super::super::__buffa::view::oneof::value::Kind::NumberValue(_x) => {
                    size += 1u32 + ::buffa::types::FIXED64_ENCODED_LEN as u32;
                }
                super::super::__buffa::view::oneof::value::Kind::StringValue(x) => {
                    size += 1u32 + ::buffa::types::string_encoded_len(x) as u32;
                }
                super::super::__buffa::view::oneof::value::Kind::BoolValue(_x) => {
                    size += 1u32 + ::buffa::types::BOOL_ENCODED_LEN as u32;
                }
                super::super::__buffa::view::oneof::value::Kind::StructValue(x) => {
                    let __slot = __cache.reserve();
                    let inner = x.compute_size(__cache);
                    __cache.set(__slot, inner);
                    size
                        += 1u32 + ::buffa::encoding::varint_len(inner as u64) as u32
                            + inner;
                }
                super::super::__buffa::view::oneof::value::Kind::ListValue(x) => {
                    let __slot = __cache.reserve();
                    let inner = x.compute_size(__cache);
                    __cache.set(__slot, inner);
                    size
                        += 1u32 + ::buffa::encoding::varint_len(inner as u64) as u32
                            + inner;
                }
            }
        }
        size += self.__buffa_unknown_fields.encoded_len() as u32;
        size
    }
    #[allow(clippy::needless_borrow)]
    fn write_to(
        &self,
        __cache: &mut ::buffa::SizeCache,
        buf: &mut impl ::buffa::bytes::BufMut,
    ) {
        #[allow(unused_imports)]
        use ::buffa::Enumeration as _;
        if let ::core::option::Option::Some(ref v) = self.kind {
            match v {
                super::super::__buffa::view::oneof::value::Kind::NullValue(x) => {
                    ::buffa::encoding::Tag::new(
                            1u32,
                            ::buffa::encoding::WireType::Varint,
                        )
                        .encode(buf);
                    ::buffa::types::encode_int32(x.to_i32(), buf);
                }
                super::super::__buffa::view::oneof::value::Kind::NumberValue(x) => {
                    ::buffa::encoding::Tag::new(
                            2u32,
                            ::buffa::encoding::WireType::Fixed64,
                        )
                        .encode(buf);
                    ::buffa::types::encode_double(*x, buf);
                }
                super::super::__buffa::view::oneof::value::Kind::StringValue(x) => {
                    ::buffa::encoding::Tag::new(
                            3u32,
                            ::buffa::encoding::WireType::LengthDelimited,
                        )
                        .encode(buf);
                    ::buffa::types::encode_string(x, buf);
                }
                super::super::__buffa::view::oneof::value::Kind::BoolValue(x) => {
                    ::buffa::encoding::Tag::new(
                            4u32,
                            ::buffa::encoding::WireType::Varint,
                        )
                        .encode(buf);
                    ::buffa::types::encode_bool(*x, buf);
                }
                super::super::__buffa::view::oneof::value::Kind::StructValue(x) => {
                    ::buffa::encoding::Tag::new(
                            5u32,
                            ::buffa::encoding::WireType::LengthDelimited,
                        )
                        .encode(buf);
                    ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf);
                    x.write_to(__cache, buf);
                }
                super::super::__buffa::view::oneof::value::Kind::ListValue(x) => {
                    ::buffa::encoding::Tag::new(
                            6u32,
                            ::buffa::encoding::WireType::LengthDelimited,
                        )
                        .encode(buf);
                    ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf);
                    x.write_to(__cache, buf);
                }
            }
        }
        self.__buffa_unknown_fields.write_to(buf);
    }
}
impl<'v> ::buffa::DefaultViewInstance for ValueView<'v> {
    fn default_view_instance<'a>() -> &'a Self
    where
        Self: 'a,
    {
        static VALUE: ::buffa::__private::OnceBox<ValueView<'static>> = ::buffa::__private::OnceBox::new();
        VALUE
            .get_or_init(|| ::buffa::alloc::boxed::Box::new(
                <ValueView<'static>>::default(),
            ))
    }
}
/// `ListValue` is a wrapper around a repeated field of values.
///
/// The JSON representation for `ListValue` is JSON array.
#[derive(Clone, Debug, Default)]
pub struct ListValueView<'a> {
    /// Repeated field of dynamically typed values.
    ///
    /// Field 1: `values`
    pub values: ::buffa::RepeatedView<'a, super::super::__buffa::view::ValueView<'a>>,
    pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
}
impl<'a> ListValueView<'a> {
    /// Decode from `buf`, enforcing a recursion depth limit for nested messages.
    ///
    /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`]
    /// and by generated sub-message decode arms with `depth - 1`.
    ///
    /// **Not part of the public API.** Named with a leading underscore to
    /// signal that it is for generated-code use only.
    #[doc(hidden)]
    pub fn _decode_depth(
        buf: &'a [u8],
        depth: u32,
    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
        let mut view = Self::default();
        view._merge_into_view(buf, depth)?;
        ::core::result::Result::Ok(view)
    }
    /// Merge fields from `buf` into this view (proto merge semantics).
    ///
    /// Repeated fields append; singular fields last-wins; singular
    /// MESSAGE fields merge recursively. Used by sub-message decode
    /// arms when the same field appears multiple times on the wire.
    ///
    /// **Not part of the public API.**
    #[doc(hidden)]
    pub fn _merge_into_view(
        &mut self,
        buf: &'a [u8],
        depth: u32,
    ) -> ::core::result::Result<(), ::buffa::DecodeError> {
        let _ = depth;
        #[allow(unused_variables)]
        let view = self;
        let mut cur: &'a [u8] = buf;
        while !cur.is_empty() {
            let before_tag = cur;
            let tag = ::buffa::encoding::Tag::decode(&mut cur)?;
            match tag.field_number() {
                1u32 => {
                    if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
                        return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
                            field_number: 1u32,
                            expected: 2u8,
                            actual: tag.wire_type() as u8,
                        });
                    }
                    if depth == 0 {
                        return Err(::buffa::DecodeError::RecursionLimitExceeded);
                    }
                    let sub = ::buffa::types::borrow_bytes(&mut cur)?;
                    view.values
                        .push(
                            super::super::__buffa::view::ValueView::_decode_depth(
                                sub,
                                depth - 1,
                            )?,
                        );
                }
                _ => {
                    ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?;
                    let span_len = before_tag.len() - cur.len();
                    view.__buffa_unknown_fields.push_raw(&before_tag[..span_len]);
                }
            }
        }
        ::core::result::Result::Ok(())
    }
}
impl<'a> ::buffa::MessageView<'a> for ListValueView<'a> {
    type Owned = super::super::ListValue;
    fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
        Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT)
    }
    fn decode_view_with_limit(
        buf: &'a [u8],
        depth: u32,
    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
        Self::_decode_depth(buf, depth)
    }
    /// Convert this view to the owned message type.
    #[allow(clippy::redundant_closure, clippy::useless_conversion)]
    #[allow(clippy::needless_update)]
    fn to_owned_message(&self) -> super::super::ListValue {
        #[allow(unused_imports)]
        use ::buffa::alloc::string::ToString as _;
        super::super::ListValue {
            values: self.values.iter().map(|v| v.to_owned_message()).collect(),
            __buffa_unknown_fields: self
                .__buffa_unknown_fields
                .to_owned()
                .unwrap_or_default()
                .into(),
            ..::core::default::Default::default()
        }
    }
}
impl<'a> ::buffa::ViewEncode<'a> for ListValueView<'a> {
    #[allow(clippy::needless_borrow, clippy::let_and_return)]
    fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 {
        #[allow(unused_imports)]
        use ::buffa::Enumeration as _;
        let mut size = 0u32;
        for v in &self.values {
            let __slot = __cache.reserve();
            let inner_size = v.compute_size(__cache);
            __cache.set(__slot, inner_size);
            size
                += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
                    + inner_size;
        }
        size += self.__buffa_unknown_fields.encoded_len() as u32;
        size
    }
    #[allow(clippy::needless_borrow)]
    fn write_to(
        &self,
        __cache: &mut ::buffa::SizeCache,
        buf: &mut impl ::buffa::bytes::BufMut,
    ) {
        #[allow(unused_imports)]
        use ::buffa::Enumeration as _;
        for v in &self.values {
            ::buffa::encoding::Tag::new(
                    1u32,
                    ::buffa::encoding::WireType::LengthDelimited,
                )
                .encode(buf);
            ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf);
            v.write_to(__cache, buf);
        }
        self.__buffa_unknown_fields.write_to(buf);
    }
}
impl<'v> ::buffa::DefaultViewInstance for ListValueView<'v> {
    fn default_view_instance<'a>() -> &'a Self
    where
        Self: 'a,
    {
        static VALUE: ::buffa::__private::OnceBox<ListValueView<'static>> = ::buffa::__private::OnceBox::new();
        VALUE
            .get_or_init(|| ::buffa::alloc::boxed::Box::new(
                <ListValueView<'static>>::default(),
            ))
    }
}