Skip to main content

buffa_types/generated/
google.protobuf.struct.rs

1// @generated by protoc-gen-buffa. DO NOT EDIT.
2// source: google/protobuf/struct.proto
3
4#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
5#[cfg_attr(feature = "arbitrary", derive(::arbitrary::Arbitrary))]
6#[repr(i32)]
7pub enum NullValue {
8    NULL_VALUE = 0i32,
9}
10impl ::core::default::Default for NullValue {
11    fn default() -> Self {
12        Self::NULL_VALUE
13    }
14}
15impl ::buffa::Enumeration for NullValue {
16    fn from_i32(value: i32) -> ::core::option::Option<Self> {
17        match value {
18            0i32 => ::core::option::Option::Some(Self::NULL_VALUE),
19            _ => ::core::option::Option::None,
20        }
21    }
22    fn to_i32(&self) -> i32 {
23        *self as i32
24    }
25    fn proto_name(&self) -> &'static str {
26        match self {
27            Self::NULL_VALUE => "NULL_VALUE",
28        }
29    }
30    fn from_proto_name(name: &str) -> ::core::option::Option<Self> {
31        match name {
32            "NULL_VALUE" => ::core::option::Option::Some(Self::NULL_VALUE),
33            _ => ::core::option::Option::None,
34        }
35    }
36}
37#[derive(Clone, PartialEq, Default)]
38#[cfg_attr(feature = "arbitrary", derive(::arbitrary::Arbitrary))]
39pub struct Struct {
40    ///Field 1: `fields`
41    pub fields: ::buffa::__private::HashMap<::buffa::alloc::string::String, Value>,
42    #[doc(hidden)]
43    pub __buffa_unknown_fields: ::buffa::UnknownFields,
44    #[doc(hidden)]
45    pub __buffa_cached_size: ::buffa::__private::CachedSize,
46}
47impl ::core::fmt::Debug for Struct {
48    fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
49        f.debug_struct("Struct").field("fields", &self.fields).finish()
50    }
51}
52impl Struct {
53    /// Protobuf type URL for this message, for use with `Any::pack` and
54    /// `Any::unpack_if`.
55    ///
56    /// Format: `type.googleapis.com/<fully.qualified.TypeName>`
57    pub const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.Struct";
58}
59unsafe impl ::buffa::DefaultInstance for Struct {
60    fn default_instance() -> &'static Self {
61        static VALUE: ::buffa::__private::OnceBox<Struct> = ::buffa::__private::OnceBox::new();
62        VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Struct::default()))
63    }
64}
65impl ::buffa::Message for Struct {
66    /// Returns the total encoded size in bytes.
67    ///
68    /// The result is a `u32`; the protobuf specification requires all
69    /// messages to fit within 2 GiB (2,147,483,647 bytes), so a
70    /// compliant message will never overflow this type.
71    fn compute_size(&self) -> u32 {
72        #[allow(unused_imports)]
73        use ::buffa::Enumeration as _;
74        let mut size = 0u32;
75        for (k, v) in &self.fields {
76            let entry_size: u32 = 1u32 + ::buffa::types::string_encoded_len(k) as u32
77                + 1u32
78                + {
79                    let inner = v.compute_size();
80                    ::buffa::encoding::varint_len(inner as u64) as u32 + inner
81                };
82            size
83                += 1u32 + ::buffa::encoding::varint_len(entry_size as u64) as u32
84                    + entry_size;
85        }
86        size += self.__buffa_unknown_fields.encoded_len() as u32;
87        self.__buffa_cached_size.set(size);
88        size
89    }
90    fn write_to(&self, buf: &mut impl ::buffa::bytes::BufMut) {
91        #[allow(unused_imports)]
92        use ::buffa::Enumeration as _;
93        for (k, v) in &self.fields {
94            let entry_size: u32 = 1u32 + ::buffa::types::string_encoded_len(k) as u32
95                + 1u32
96                + {
97                    let inner = v.compute_size();
98                    ::buffa::encoding::varint_len(inner as u64) as u32 + inner
99                };
100            ::buffa::encoding::Tag::new(
101                    1u32,
102                    ::buffa::encoding::WireType::LengthDelimited,
103                )
104                .encode(buf);
105            ::buffa::encoding::encode_varint(entry_size as u64, buf);
106            ::buffa::encoding::Tag::new(
107                    1u32,
108                    ::buffa::encoding::WireType::LengthDelimited,
109                )
110                .encode(buf);
111            ::buffa::types::encode_string(k, buf);
112            ::buffa::encoding::Tag::new(
113                    2u32,
114                    ::buffa::encoding::WireType::LengthDelimited,
115                )
116                .encode(buf);
117            ::buffa::encoding::encode_varint(v.cached_size() as u64, buf);
118            v.write_to(buf);
119        }
120        self.__buffa_unknown_fields.write_to(buf);
121    }
122    fn merge_field(
123        &mut self,
124        tag: ::buffa::encoding::Tag,
125        buf: &mut impl ::buffa::bytes::Buf,
126        depth: u32,
127    ) -> ::core::result::Result<(), ::buffa::DecodeError> {
128        #[allow(unused_imports)]
129        use ::buffa::bytes::Buf as _;
130        #[allow(unused_imports)]
131        use ::buffa::Enumeration as _;
132        match tag.field_number() {
133            1u32 => {
134                if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
135                    return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
136                        field_number: 1u32,
137                        expected: 2u8,
138                        actual: tag.wire_type() as u8,
139                    });
140                }
141                let entry_len = ::buffa::encoding::decode_varint(buf)?;
142                let entry_len = usize::try_from(entry_len)
143                    .map_err(|_| ::buffa::DecodeError::MessageTooLarge)?;
144                if buf.remaining() < entry_len {
145                    return ::core::result::Result::Err(
146                        ::buffa::DecodeError::UnexpectedEof,
147                    );
148                }
149                let entry_limit = buf.remaining() - entry_len;
150                let mut key = ::core::default::Default::default();
151                let mut val = ::core::default::Default::default();
152                while buf.remaining() > entry_limit {
153                    let entry_tag = ::buffa::encoding::Tag::decode(buf)?;
154                    match entry_tag.field_number() {
155                        1 => {
156                            if entry_tag.wire_type()
157                                != ::buffa::encoding::WireType::LengthDelimited
158                            {
159                                return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
160                                    field_number: entry_tag.field_number(),
161                                    expected: 2u8,
162                                    actual: entry_tag.wire_type() as u8,
163                                });
164                            }
165                            key = ::buffa::types::decode_string(buf)?;
166                        }
167                        2 => {
168                            if entry_tag.wire_type()
169                                != ::buffa::encoding::WireType::LengthDelimited
170                            {
171                                return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
172                                    field_number: entry_tag.field_number(),
173                                    expected: 2u8,
174                                    actual: entry_tag.wire_type() as u8,
175                                });
176                            }
177                            ::buffa::Message::merge_length_delimited(
178                                &mut val,
179                                buf,
180                                depth,
181                            )?;
182                        }
183                        _ => {
184                            ::buffa::encoding::skip_field_depth(entry_tag, buf, depth)?;
185                        }
186                    }
187                }
188                if buf.remaining() != entry_limit {
189                    let remaining = buf.remaining();
190                    if remaining > entry_limit {
191                        buf.advance(remaining - entry_limit);
192                    } else {
193                        return ::core::result::Result::Err(
194                            ::buffa::DecodeError::UnexpectedEof,
195                        );
196                    }
197                }
198                self.fields.insert(key, val);
199            }
200            _ => {
201                self.__buffa_unknown_fields
202                    .push(::buffa::encoding::decode_unknown_field(tag, buf, depth)?);
203            }
204        }
205        ::core::result::Result::Ok(())
206    }
207    fn cached_size(&self) -> u32 {
208        self.__buffa_cached_size.get()
209    }
210    fn clear(&mut self) {
211        self.fields.clear();
212        self.__buffa_unknown_fields.clear();
213        self.__buffa_cached_size.set(0);
214    }
215}
216#[derive(Clone, Debug, Default)]
217pub struct StructView<'a> {
218    ///Field 1: `fields` (map)
219    pub fields: ::buffa::MapView<'a, &'a str, ValueView<'a>>,
220    pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
221}
222impl<'a> StructView<'a> {
223    /// Decode from `buf`, enforcing a recursion depth limit for nested messages.
224    ///
225    /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`]
226    /// and by generated sub-message decode arms with `depth - 1`.
227    ///
228    /// **Not part of the public API.** Named with a leading underscore to
229    /// signal that it is for generated-code use only.
230    #[doc(hidden)]
231    pub fn _decode_depth(
232        buf: &'a [u8],
233        depth: u32,
234    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
235        let mut view = Self::default();
236        view._merge_into_view(buf, depth)?;
237        ::core::result::Result::Ok(view)
238    }
239    /// Merge fields from `buf` into this view (proto merge semantics).
240    ///
241    /// Repeated fields append; singular fields last-wins; singular
242    /// MESSAGE fields merge recursively. Used by sub-message decode
243    /// arms when the same field appears multiple times on the wire.
244    ///
245    /// **Not part of the public API.**
246    #[doc(hidden)]
247    pub fn _merge_into_view(
248        &mut self,
249        buf: &'a [u8],
250        depth: u32,
251    ) -> ::core::result::Result<(), ::buffa::DecodeError> {
252        let _ = depth;
253        #[allow(unused_variables)]
254        let view = self;
255        let mut cur: &'a [u8] = buf;
256        while !cur.is_empty() {
257            let before_tag = cur;
258            let tag = ::buffa::encoding::Tag::decode(&mut cur)?;
259            match tag.field_number() {
260                1u32 => {
261                    if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
262                        return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
263                            field_number: 1u32,
264                            expected: 2u8,
265                            actual: tag.wire_type() as u8,
266                        });
267                    }
268                    let entry_bytes = ::buffa::types::borrow_bytes(&mut cur)?;
269                    let mut entry_cur: &'a [u8] = entry_bytes;
270                    let mut key = "";
271                    let mut val = ::core::default::Default::default();
272                    while !entry_cur.is_empty() {
273                        let entry_tag = ::buffa::encoding::Tag::decode(&mut entry_cur)?;
274                        match entry_tag.field_number() {
275                            1 => {
276                                if entry_tag.wire_type()
277                                    != ::buffa::encoding::WireType::LengthDelimited
278                                {
279                                    return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
280                                        field_number: entry_tag.field_number(),
281                                        expected: 2u8,
282                                        actual: entry_tag.wire_type() as u8,
283                                    });
284                                }
285                                key = ::buffa::types::borrow_str(&mut entry_cur)?;
286                            }
287                            2 => {
288                                if entry_tag.wire_type()
289                                    != ::buffa::encoding::WireType::LengthDelimited
290                                {
291                                    return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
292                                        field_number: entry_tag.field_number(),
293                                        expected: 2u8,
294                                        actual: entry_tag.wire_type() as u8,
295                                    });
296                                }
297                                if depth == 0 {
298                                    return Err(::buffa::DecodeError::RecursionLimitExceeded);
299                                }
300                                let sub = ::buffa::types::borrow_bytes(&mut entry_cur)?;
301                                val = ValueView::_decode_depth(sub, depth - 1)?;
302                            }
303                            _ => {
304                                ::buffa::encoding::skip_field_depth(
305                                    entry_tag,
306                                    &mut entry_cur,
307                                    depth,
308                                )?;
309                            }
310                        }
311                    }
312                    view.fields.push(key, val);
313                }
314                _ => {
315                    ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?;
316                    let span_len = before_tag.len() - cur.len();
317                    view.__buffa_unknown_fields.push_raw(&before_tag[..span_len]);
318                }
319            }
320        }
321        ::core::result::Result::Ok(())
322    }
323}
324impl<'a> ::buffa::MessageView<'a> for StructView<'a> {
325    type Owned = Struct;
326    fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
327        Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT)
328    }
329    fn decode_view_with_limit(
330        buf: &'a [u8],
331        depth: u32,
332    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
333        Self::_decode_depth(buf, depth)
334    }
335    /// Convert this view to the owned message type.
336    #[allow(clippy::redundant_closure)]
337    fn to_owned_message(&self) -> Struct {
338        #[allow(unused_imports)]
339        use ::buffa::alloc::string::ToString as _;
340        Struct {
341            fields: self
342                .fields
343                .iter()
344                .map(|(k, v)| (k.to_string(), v.to_owned_message()))
345                .collect(),
346            __buffa_unknown_fields: self
347                .__buffa_unknown_fields
348                .to_owned()
349                .unwrap_or_default(),
350            ..::core::default::Default::default()
351        }
352    }
353}
354unsafe impl ::buffa::DefaultViewInstance for StructView<'static> {
355    fn default_view_instance() -> &'static Self {
356        static VALUE: ::buffa::__private::OnceBox<StructView<'static>> = ::buffa::__private::OnceBox::new();
357        VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(StructView::default()))
358    }
359}
360unsafe impl<'a> ::buffa::HasDefaultViewInstance for StructView<'a> {
361    type Static = StructView<'static>;
362}
363#[derive(Clone, PartialEq, Default)]
364#[cfg_attr(feature = "arbitrary", derive(::arbitrary::Arbitrary))]
365pub struct Value {
366    pub kind: Option<value::Kind>,
367    #[doc(hidden)]
368    pub __buffa_unknown_fields: ::buffa::UnknownFields,
369    #[doc(hidden)]
370    pub __buffa_cached_size: ::buffa::__private::CachedSize,
371}
372impl ::core::fmt::Debug for Value {
373    fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
374        f.debug_struct("Value").field("kind", &self.kind).finish()
375    }
376}
377impl Value {
378    /// Protobuf type URL for this message, for use with `Any::pack` and
379    /// `Any::unpack_if`.
380    ///
381    /// Format: `type.googleapis.com/<fully.qualified.TypeName>`
382    pub const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.Value";
383}
384unsafe impl ::buffa::DefaultInstance for Value {
385    fn default_instance() -> &'static Self {
386        static VALUE: ::buffa::__private::OnceBox<Value> = ::buffa::__private::OnceBox::new();
387        VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Value::default()))
388    }
389}
390impl ::buffa::Message for Value {
391    /// Returns the total encoded size in bytes.
392    ///
393    /// The result is a `u32`; the protobuf specification requires all
394    /// messages to fit within 2 GiB (2,147,483,647 bytes), so a
395    /// compliant message will never overflow this type.
396    fn compute_size(&self) -> u32 {
397        #[allow(unused_imports)]
398        use ::buffa::Enumeration as _;
399        let mut size = 0u32;
400        if let ::core::option::Option::Some(ref v) = self.kind {
401            match v {
402                value::Kind::NullValue(x) => {
403                    size += 1u32 + ::buffa::types::int32_encoded_len(x.to_i32()) as u32;
404                }
405                value::Kind::NumberValue(_x) => {
406                    size += 1u32 + ::buffa::types::FIXED64_ENCODED_LEN as u32;
407                }
408                value::Kind::StringValue(x) => {
409                    size += 1u32 + ::buffa::types::string_encoded_len(x) as u32;
410                }
411                value::Kind::BoolValue(_x) => {
412                    size += 1u32 + ::buffa::types::BOOL_ENCODED_LEN as u32;
413                }
414                value::Kind::StructValue(x) => {
415                    let inner = x.compute_size();
416                    size
417                        += 1u32 + ::buffa::encoding::varint_len(inner as u64) as u32
418                            + inner;
419                }
420                value::Kind::ListValue(x) => {
421                    let inner = x.compute_size();
422                    size
423                        += 1u32 + ::buffa::encoding::varint_len(inner as u64) as u32
424                            + inner;
425                }
426            }
427        }
428        size += self.__buffa_unknown_fields.encoded_len() as u32;
429        self.__buffa_cached_size.set(size);
430        size
431    }
432    fn write_to(&self, buf: &mut impl ::buffa::bytes::BufMut) {
433        #[allow(unused_imports)]
434        use ::buffa::Enumeration as _;
435        if let ::core::option::Option::Some(ref v) = self.kind {
436            match v {
437                value::Kind::NullValue(x) => {
438                    ::buffa::encoding::Tag::new(
439                            1u32,
440                            ::buffa::encoding::WireType::Varint,
441                        )
442                        .encode(buf);
443                    ::buffa::types::encode_int32(x.to_i32(), buf);
444                }
445                value::Kind::NumberValue(x) => {
446                    ::buffa::encoding::Tag::new(
447                            2u32,
448                            ::buffa::encoding::WireType::Fixed64,
449                        )
450                        .encode(buf);
451                    ::buffa::types::encode_double(*x, buf);
452                }
453                value::Kind::StringValue(x) => {
454                    ::buffa::encoding::Tag::new(
455                            3u32,
456                            ::buffa::encoding::WireType::LengthDelimited,
457                        )
458                        .encode(buf);
459                    ::buffa::types::encode_string(x, buf);
460                }
461                value::Kind::BoolValue(x) => {
462                    ::buffa::encoding::Tag::new(
463                            4u32,
464                            ::buffa::encoding::WireType::Varint,
465                        )
466                        .encode(buf);
467                    ::buffa::types::encode_bool(*x, buf);
468                }
469                value::Kind::StructValue(x) => {
470                    ::buffa::encoding::Tag::new(
471                            5u32,
472                            ::buffa::encoding::WireType::LengthDelimited,
473                        )
474                        .encode(buf);
475                    ::buffa::encoding::encode_varint(x.cached_size() as u64, buf);
476                    x.write_to(buf);
477                }
478                value::Kind::ListValue(x) => {
479                    ::buffa::encoding::Tag::new(
480                            6u32,
481                            ::buffa::encoding::WireType::LengthDelimited,
482                        )
483                        .encode(buf);
484                    ::buffa::encoding::encode_varint(x.cached_size() as u64, buf);
485                    x.write_to(buf);
486                }
487            }
488        }
489        self.__buffa_unknown_fields.write_to(buf);
490    }
491    fn merge_field(
492        &mut self,
493        tag: ::buffa::encoding::Tag,
494        buf: &mut impl ::buffa::bytes::Buf,
495        depth: u32,
496    ) -> ::core::result::Result<(), ::buffa::DecodeError> {
497        #[allow(unused_imports)]
498        use ::buffa::bytes::Buf as _;
499        #[allow(unused_imports)]
500        use ::buffa::Enumeration as _;
501        match tag.field_number() {
502            1u32 => {
503                if tag.wire_type() != ::buffa::encoding::WireType::Varint {
504                    return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
505                        field_number: 1u32,
506                        expected: 0u8,
507                        actual: tag.wire_type() as u8,
508                    });
509                }
510                self.kind = ::core::option::Option::Some(
511                    value::Kind::NullValue(
512                        ::buffa::EnumValue::from(::buffa::types::decode_int32(buf)?),
513                    ),
514                );
515            }
516            2u32 => {
517                if tag.wire_type() != ::buffa::encoding::WireType::Fixed64 {
518                    return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
519                        field_number: 2u32,
520                        expected: 1u8,
521                        actual: tag.wire_type() as u8,
522                    });
523                }
524                self.kind = ::core::option::Option::Some(
525                    value::Kind::NumberValue(::buffa::types::decode_double(buf)?),
526                );
527            }
528            3u32 => {
529                if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
530                    return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
531                        field_number: 3u32,
532                        expected: 2u8,
533                        actual: tag.wire_type() as u8,
534                    });
535                }
536                self.kind = ::core::option::Option::Some(
537                    value::Kind::StringValue(::buffa::types::decode_string(buf)?),
538                );
539            }
540            4u32 => {
541                if tag.wire_type() != ::buffa::encoding::WireType::Varint {
542                    return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
543                        field_number: 4u32,
544                        expected: 0u8,
545                        actual: tag.wire_type() as u8,
546                    });
547                }
548                self.kind = ::core::option::Option::Some(
549                    value::Kind::BoolValue(::buffa::types::decode_bool(buf)?),
550                );
551            }
552            5u32 => {
553                if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
554                    return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
555                        field_number: 5u32,
556                        expected: 2u8,
557                        actual: tag.wire_type() as u8,
558                    });
559                }
560                if let ::core::option::Option::Some(
561                    value::Kind::StructValue(ref mut existing),
562                ) = self.kind
563                {
564                    ::buffa::Message::merge_length_delimited(
565                        &mut **existing,
566                        buf,
567                        depth,
568                    )?;
569                } else {
570                    let mut val = ::core::default::Default::default();
571                    ::buffa::Message::merge_length_delimited(&mut val, buf, depth)?;
572                    self.kind = ::core::option::Option::Some(
573                        value::Kind::StructValue(::buffa::alloc::boxed::Box::new(val)),
574                    );
575                }
576            }
577            6u32 => {
578                if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
579                    return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
580                        field_number: 6u32,
581                        expected: 2u8,
582                        actual: tag.wire_type() as u8,
583                    });
584                }
585                if let ::core::option::Option::Some(
586                    value::Kind::ListValue(ref mut existing),
587                ) = self.kind
588                {
589                    ::buffa::Message::merge_length_delimited(
590                        &mut **existing,
591                        buf,
592                        depth,
593                    )?;
594                } else {
595                    let mut val = ::core::default::Default::default();
596                    ::buffa::Message::merge_length_delimited(&mut val, buf, depth)?;
597                    self.kind = ::core::option::Option::Some(
598                        value::Kind::ListValue(::buffa::alloc::boxed::Box::new(val)),
599                    );
600                }
601            }
602            _ => {
603                self.__buffa_unknown_fields
604                    .push(::buffa::encoding::decode_unknown_field(tag, buf, depth)?);
605            }
606        }
607        ::core::result::Result::Ok(())
608    }
609    fn cached_size(&self) -> u32 {
610        self.__buffa_cached_size.get()
611    }
612    fn clear(&mut self) {
613        self.kind = ::core::option::Option::None;
614        self.__buffa_unknown_fields.clear();
615        self.__buffa_cached_size.set(0);
616    }
617}
618#[derive(Clone, Debug, Default)]
619pub struct ValueView<'a> {
620    pub kind: ::core::option::Option<value::KindView<'a>>,
621    pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
622}
623impl<'a> ValueView<'a> {
624    /// Decode from `buf`, enforcing a recursion depth limit for nested messages.
625    ///
626    /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`]
627    /// and by generated sub-message decode arms with `depth - 1`.
628    ///
629    /// **Not part of the public API.** Named with a leading underscore to
630    /// signal that it is for generated-code use only.
631    #[doc(hidden)]
632    pub fn _decode_depth(
633        buf: &'a [u8],
634        depth: u32,
635    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
636        let mut view = Self::default();
637        view._merge_into_view(buf, depth)?;
638        ::core::result::Result::Ok(view)
639    }
640    /// Merge fields from `buf` into this view (proto merge semantics).
641    ///
642    /// Repeated fields append; singular fields last-wins; singular
643    /// MESSAGE fields merge recursively. Used by sub-message decode
644    /// arms when the same field appears multiple times on the wire.
645    ///
646    /// **Not part of the public API.**
647    #[doc(hidden)]
648    pub fn _merge_into_view(
649        &mut self,
650        buf: &'a [u8],
651        depth: u32,
652    ) -> ::core::result::Result<(), ::buffa::DecodeError> {
653        let _ = depth;
654        #[allow(unused_variables)]
655        let view = self;
656        let mut cur: &'a [u8] = buf;
657        while !cur.is_empty() {
658            let before_tag = cur;
659            let tag = ::buffa::encoding::Tag::decode(&mut cur)?;
660            match tag.field_number() {
661                1u32 => {
662                    if tag.wire_type() != ::buffa::encoding::WireType::Varint {
663                        return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
664                            field_number: 1u32,
665                            expected: 0u8,
666                            actual: tag.wire_type() as u8,
667                        });
668                    }
669                    view.kind = Some(
670                        value::KindView::NullValue(
671                            ::buffa::EnumValue::from(
672                                ::buffa::types::decode_int32(&mut cur)?,
673                            ),
674                        ),
675                    );
676                }
677                2u32 => {
678                    if tag.wire_type() != ::buffa::encoding::WireType::Fixed64 {
679                        return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
680                            field_number: 2u32,
681                            expected: 1u8,
682                            actual: tag.wire_type() as u8,
683                        });
684                    }
685                    view.kind = Some(
686                        value::KindView::NumberValue(
687                            ::buffa::types::decode_double(&mut cur)?,
688                        ),
689                    );
690                }
691                3u32 => {
692                    if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
693                        return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
694                            field_number: 3u32,
695                            expected: 2u8,
696                            actual: tag.wire_type() as u8,
697                        });
698                    }
699                    view.kind = Some(
700                        value::KindView::StringValue(
701                            ::buffa::types::borrow_str(&mut cur)?,
702                        ),
703                    );
704                }
705                4u32 => {
706                    if tag.wire_type() != ::buffa::encoding::WireType::Varint {
707                        return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
708                            field_number: 4u32,
709                            expected: 0u8,
710                            actual: tag.wire_type() as u8,
711                        });
712                    }
713                    view.kind = Some(
714                        value::KindView::BoolValue(
715                            ::buffa::types::decode_bool(&mut cur)?,
716                        ),
717                    );
718                }
719                5u32 => {
720                    if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
721                        return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
722                            field_number: 5u32,
723                            expected: 2u8,
724                            actual: tag.wire_type() as u8,
725                        });
726                    }
727                    if depth == 0 {
728                        return Err(::buffa::DecodeError::RecursionLimitExceeded);
729                    }
730                    let sub = ::buffa::types::borrow_bytes(&mut cur)?;
731                    if let Some(value::KindView::StructValue(ref mut existing)) = view
732                        .kind
733                    {
734                        existing._merge_into_view(sub, depth - 1)?;
735                    } else {
736                        view.kind = Some(
737                            value::KindView::StructValue(
738                                ::buffa::alloc::boxed::Box::new(
739                                    StructView::_decode_depth(sub, depth - 1)?,
740                                ),
741                            ),
742                        );
743                    }
744                }
745                6u32 => {
746                    if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
747                        return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
748                            field_number: 6u32,
749                            expected: 2u8,
750                            actual: tag.wire_type() as u8,
751                        });
752                    }
753                    if depth == 0 {
754                        return Err(::buffa::DecodeError::RecursionLimitExceeded);
755                    }
756                    let sub = ::buffa::types::borrow_bytes(&mut cur)?;
757                    if let Some(value::KindView::ListValue(ref mut existing)) = view.kind
758                    {
759                        existing._merge_into_view(sub, depth - 1)?;
760                    } else {
761                        view.kind = Some(
762                            value::KindView::ListValue(
763                                ::buffa::alloc::boxed::Box::new(
764                                    ListValueView::_decode_depth(sub, depth - 1)?,
765                                ),
766                            ),
767                        );
768                    }
769                }
770                _ => {
771                    ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?;
772                    let span_len = before_tag.len() - cur.len();
773                    view.__buffa_unknown_fields.push_raw(&before_tag[..span_len]);
774                }
775            }
776        }
777        ::core::result::Result::Ok(())
778    }
779}
780impl<'a> ::buffa::MessageView<'a> for ValueView<'a> {
781    type Owned = Value;
782    fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
783        Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT)
784    }
785    fn decode_view_with_limit(
786        buf: &'a [u8],
787        depth: u32,
788    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
789        Self::_decode_depth(buf, depth)
790    }
791    /// Convert this view to the owned message type.
792    #[allow(clippy::redundant_closure)]
793    fn to_owned_message(&self) -> Value {
794        #[allow(unused_imports)]
795        use ::buffa::alloc::string::ToString as _;
796        Value {
797            kind: self
798                .kind
799                .as_ref()
800                .map(|v| match v {
801                    value::KindView::NullValue(v) => value::Kind::NullValue(*v),
802                    value::KindView::NumberValue(v) => value::Kind::NumberValue(*v),
803                    value::KindView::StringValue(v) => {
804                        value::Kind::StringValue(v.to_string())
805                    }
806                    value::KindView::BoolValue(v) => value::Kind::BoolValue(*v),
807                    value::KindView::StructValue(v) => {
808                        value::Kind::StructValue(
809                            ::buffa::alloc::boxed::Box::new(v.to_owned_message()),
810                        )
811                    }
812                    value::KindView::ListValue(v) => {
813                        value::Kind::ListValue(
814                            ::buffa::alloc::boxed::Box::new(v.to_owned_message()),
815                        )
816                    }
817                }),
818            __buffa_unknown_fields: self
819                .__buffa_unknown_fields
820                .to_owned()
821                .unwrap_or_default(),
822            ..::core::default::Default::default()
823        }
824    }
825}
826unsafe impl ::buffa::DefaultViewInstance for ValueView<'static> {
827    fn default_view_instance() -> &'static Self {
828        static VALUE: ::buffa::__private::OnceBox<ValueView<'static>> = ::buffa::__private::OnceBox::new();
829        VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(ValueView::default()))
830    }
831}
832unsafe impl<'a> ::buffa::HasDefaultViewInstance for ValueView<'a> {
833    type Static = ValueView<'static>;
834}
835pub mod value {
836    #[allow(unused_imports)]
837    use super::*;
838    #[derive(Clone, PartialEq, Debug)]
839    #[cfg_attr(feature = "arbitrary", derive(::arbitrary::Arbitrary))]
840    pub enum Kind {
841        NullValue(::buffa::EnumValue<super::NullValue>),
842        NumberValue(f64),
843        StringValue(::buffa::alloc::string::String),
844        BoolValue(bool),
845        StructValue(::buffa::alloc::boxed::Box<super::Struct>),
846        ListValue(::buffa::alloc::boxed::Box<super::ListValue>),
847    }
848    impl ::buffa::Oneof for Kind {}
849    impl From<super::Struct> for Kind {
850        fn from(v: super::Struct) -> Self {
851            Kind::StructValue(::buffa::alloc::boxed::Box::new(v))
852        }
853    }
854    impl From<super::Struct> for ::core::option::Option<Kind> {
855        fn from(v: super::Struct) -> Self {
856            ::core::option::Option::Some(Kind::from(v))
857        }
858    }
859    impl From<super::ListValue> for Kind {
860        fn from(v: super::ListValue) -> Self {
861            Kind::ListValue(::buffa::alloc::boxed::Box::new(v))
862        }
863    }
864    impl From<super::ListValue> for ::core::option::Option<Kind> {
865        fn from(v: super::ListValue) -> Self {
866            ::core::option::Option::Some(Kind::from(v))
867        }
868    }
869    #[derive(Clone, Debug)]
870    pub enum KindView<'a> {
871        NullValue(::buffa::EnumValue<super::NullValue>),
872        NumberValue(f64),
873        StringValue(&'a str),
874        BoolValue(bool),
875        StructValue(::buffa::alloc::boxed::Box<super::StructView<'a>>),
876        ListValue(::buffa::alloc::boxed::Box<super::ListValueView<'a>>),
877    }
878}
879#[derive(Clone, PartialEq, Default)]
880#[cfg_attr(feature = "arbitrary", derive(::arbitrary::Arbitrary))]
881pub struct ListValue {
882    ///Field 1: `values`
883    pub values: ::buffa::alloc::vec::Vec<Value>,
884    #[doc(hidden)]
885    pub __buffa_unknown_fields: ::buffa::UnknownFields,
886    #[doc(hidden)]
887    pub __buffa_cached_size: ::buffa::__private::CachedSize,
888}
889impl ::core::fmt::Debug for ListValue {
890    fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
891        f.debug_struct("ListValue").field("values", &self.values).finish()
892    }
893}
894impl ListValue {
895    /// Protobuf type URL for this message, for use with `Any::pack` and
896    /// `Any::unpack_if`.
897    ///
898    /// Format: `type.googleapis.com/<fully.qualified.TypeName>`
899    pub const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.ListValue";
900}
901unsafe impl ::buffa::DefaultInstance for ListValue {
902    fn default_instance() -> &'static Self {
903        static VALUE: ::buffa::__private::OnceBox<ListValue> = ::buffa::__private::OnceBox::new();
904        VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(ListValue::default()))
905    }
906}
907impl ::buffa::Message for ListValue {
908    /// Returns the total encoded size in bytes.
909    ///
910    /// The result is a `u32`; the protobuf specification requires all
911    /// messages to fit within 2 GiB (2,147,483,647 bytes), so a
912    /// compliant message will never overflow this type.
913    fn compute_size(&self) -> u32 {
914        #[allow(unused_imports)]
915        use ::buffa::Enumeration as _;
916        let mut size = 0u32;
917        for v in &self.values {
918            let inner_size = v.compute_size();
919            size
920                += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
921                    + inner_size;
922        }
923        size += self.__buffa_unknown_fields.encoded_len() as u32;
924        self.__buffa_cached_size.set(size);
925        size
926    }
927    fn write_to(&self, buf: &mut impl ::buffa::bytes::BufMut) {
928        #[allow(unused_imports)]
929        use ::buffa::Enumeration as _;
930        for v in &self.values {
931            ::buffa::encoding::Tag::new(
932                    1u32,
933                    ::buffa::encoding::WireType::LengthDelimited,
934                )
935                .encode(buf);
936            ::buffa::encoding::encode_varint(v.cached_size() as u64, buf);
937            v.write_to(buf);
938        }
939        self.__buffa_unknown_fields.write_to(buf);
940    }
941    fn merge_field(
942        &mut self,
943        tag: ::buffa::encoding::Tag,
944        buf: &mut impl ::buffa::bytes::Buf,
945        depth: u32,
946    ) -> ::core::result::Result<(), ::buffa::DecodeError> {
947        #[allow(unused_imports)]
948        use ::buffa::bytes::Buf as _;
949        #[allow(unused_imports)]
950        use ::buffa::Enumeration as _;
951        match tag.field_number() {
952            1u32 => {
953                if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
954                    return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
955                        field_number: 1u32,
956                        expected: 2u8,
957                        actual: tag.wire_type() as u8,
958                    });
959                }
960                let mut elem = ::core::default::Default::default();
961                ::buffa::Message::merge_length_delimited(&mut elem, buf, depth)?;
962                self.values.push(elem);
963            }
964            _ => {
965                self.__buffa_unknown_fields
966                    .push(::buffa::encoding::decode_unknown_field(tag, buf, depth)?);
967            }
968        }
969        ::core::result::Result::Ok(())
970    }
971    fn cached_size(&self) -> u32 {
972        self.__buffa_cached_size.get()
973    }
974    fn clear(&mut self) {
975        self.values.clear();
976        self.__buffa_unknown_fields.clear();
977        self.__buffa_cached_size.set(0);
978    }
979}
980#[derive(Clone, Debug, Default)]
981pub struct ListValueView<'a> {
982    ///Field 1: `values`
983    pub values: ::buffa::RepeatedView<'a, ValueView<'a>>,
984    pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
985}
986impl<'a> ListValueView<'a> {
987    /// Decode from `buf`, enforcing a recursion depth limit for nested messages.
988    ///
989    /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`]
990    /// and by generated sub-message decode arms with `depth - 1`.
991    ///
992    /// **Not part of the public API.** Named with a leading underscore to
993    /// signal that it is for generated-code use only.
994    #[doc(hidden)]
995    pub fn _decode_depth(
996        buf: &'a [u8],
997        depth: u32,
998    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
999        let mut view = Self::default();
1000        view._merge_into_view(buf, depth)?;
1001        ::core::result::Result::Ok(view)
1002    }
1003    /// Merge fields from `buf` into this view (proto merge semantics).
1004    ///
1005    /// Repeated fields append; singular fields last-wins; singular
1006    /// MESSAGE fields merge recursively. Used by sub-message decode
1007    /// arms when the same field appears multiple times on the wire.
1008    ///
1009    /// **Not part of the public API.**
1010    #[doc(hidden)]
1011    pub fn _merge_into_view(
1012        &mut self,
1013        buf: &'a [u8],
1014        depth: u32,
1015    ) -> ::core::result::Result<(), ::buffa::DecodeError> {
1016        let _ = depth;
1017        #[allow(unused_variables)]
1018        let view = self;
1019        let mut cur: &'a [u8] = buf;
1020        while !cur.is_empty() {
1021            let before_tag = cur;
1022            let tag = ::buffa::encoding::Tag::decode(&mut cur)?;
1023            match tag.field_number() {
1024                1u32 => {
1025                    if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
1026                        return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
1027                            field_number: 1u32,
1028                            expected: 2u8,
1029                            actual: tag.wire_type() as u8,
1030                        });
1031                    }
1032                    if depth == 0 {
1033                        return Err(::buffa::DecodeError::RecursionLimitExceeded);
1034                    }
1035                    let sub = ::buffa::types::borrow_bytes(&mut cur)?;
1036                    view.values.push(ValueView::_decode_depth(sub, depth - 1)?);
1037                }
1038                _ => {
1039                    ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?;
1040                    let span_len = before_tag.len() - cur.len();
1041                    view.__buffa_unknown_fields.push_raw(&before_tag[..span_len]);
1042                }
1043            }
1044        }
1045        ::core::result::Result::Ok(())
1046    }
1047}
1048impl<'a> ::buffa::MessageView<'a> for ListValueView<'a> {
1049    type Owned = ListValue;
1050    fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
1051        Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT)
1052    }
1053    fn decode_view_with_limit(
1054        buf: &'a [u8],
1055        depth: u32,
1056    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
1057        Self::_decode_depth(buf, depth)
1058    }
1059    /// Convert this view to the owned message type.
1060    #[allow(clippy::redundant_closure)]
1061    fn to_owned_message(&self) -> ListValue {
1062        #[allow(unused_imports)]
1063        use ::buffa::alloc::string::ToString as _;
1064        ListValue {
1065            values: self.values.iter().map(|v| v.to_owned_message()).collect(),
1066            __buffa_unknown_fields: self
1067                .__buffa_unknown_fields
1068                .to_owned()
1069                .unwrap_or_default(),
1070            ..::core::default::Default::default()
1071        }
1072    }
1073}
1074unsafe impl ::buffa::DefaultViewInstance for ListValueView<'static> {
1075    fn default_view_instance() -> &'static Self {
1076        static VALUE: ::buffa::__private::OnceBox<ListValueView<'static>> = ::buffa::__private::OnceBox::new();
1077        VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(ListValueView::default()))
1078    }
1079}
1080unsafe impl<'a> ::buffa::HasDefaultViewInstance for ListValueView<'a> {
1081    type Static = ListValueView<'static>;
1082}