Skip to main content

buffa_types/generated/
google.protobuf.struct.rs

1// @generated by buffa-codegen. DO NOT EDIT.
2// source: google/protobuf/struct.proto
3
4/// `NullValue` is a singleton enumeration to represent the null value for the
5/// `Value` type union.
6///
7/// The JSON representation for `NullValue` is JSON `null`.
8#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
9#[cfg_attr(feature = "arbitrary", derive(::arbitrary::Arbitrary))]
10#[repr(i32)]
11pub enum NullValue {
12    /// Null value.
13    NULL_VALUE = 0i32,
14}
15impl ::core::default::Default for NullValue {
16    fn default() -> Self {
17        Self::NULL_VALUE
18    }
19}
20impl ::buffa::Enumeration for NullValue {
21    fn from_i32(value: i32) -> ::core::option::Option<Self> {
22        match value {
23            0i32 => ::core::option::Option::Some(Self::NULL_VALUE),
24            _ => ::core::option::Option::None,
25        }
26    }
27    fn to_i32(&self) -> i32 {
28        *self as i32
29    }
30    fn proto_name(&self) -> &'static str {
31        match self {
32            Self::NULL_VALUE => "NULL_VALUE",
33        }
34    }
35    fn from_proto_name(name: &str) -> ::core::option::Option<Self> {
36        match name {
37            "NULL_VALUE" => ::core::option::Option::Some(Self::NULL_VALUE),
38            _ => ::core::option::Option::None,
39        }
40    }
41    fn values() -> &'static [Self] {
42        &[Self::NULL_VALUE]
43    }
44}
45/// `Struct` represents a structured data value, consisting of fields
46/// which map to dynamically typed values. In some languages, `Struct`
47/// might be supported by a native representation. For example, in
48/// scripting languages like JS a struct is represented as an
49/// object. The details of that representation are described together
50/// with the proto support for the language.
51///
52/// The JSON representation for `Struct` is JSON object.
53#[derive(Clone, PartialEq, Default)]
54#[cfg_attr(feature = "arbitrary", derive(::arbitrary::Arbitrary))]
55pub struct Struct {
56    /// Unordered map of dynamically typed values.
57    ///
58    /// Field 1: `fields`
59    pub fields: ::buffa::__private::HashMap<::buffa::alloc::string::String, Value>,
60    #[doc(hidden)]
61    pub __buffa_unknown_fields: ::buffa::UnknownFields,
62}
63impl ::core::fmt::Debug for Struct {
64    fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
65        f.debug_struct("Struct").field("fields", &self.fields).finish()
66    }
67}
68impl Struct {
69    /// Protobuf type URL for this message, for use with `Any::pack` and
70    /// `Any::unpack_if`.
71    ///
72    /// Format: `type.googleapis.com/<fully.qualified.TypeName>`
73    pub const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.Struct";
74}
75impl ::buffa::DefaultInstance for Struct {
76    fn default_instance() -> &'static Self {
77        static VALUE: ::buffa::__private::OnceBox<Struct> = ::buffa::__private::OnceBox::new();
78        VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default()))
79    }
80}
81impl ::buffa::MessageName for Struct {
82    const PACKAGE: &'static str = "google.protobuf";
83    const NAME: &'static str = "Struct";
84    const FULL_NAME: &'static str = "google.protobuf.Struct";
85    const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.Struct";
86}
87impl ::buffa::Message for Struct {
88    /// Returns the total encoded size in bytes.
89    ///
90    /// The result is a `u32`; the protobuf specification requires all
91    /// messages to fit within 2 GiB (2,147,483,647 bytes), so a
92    /// compliant message will never overflow this type.
93    #[allow(clippy::let_and_return)]
94    fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 {
95        #[allow(unused_imports)]
96        use ::buffa::Enumeration as _;
97        let mut size = 0u32;
98        #[allow(clippy::for_kv_map)]
99        for (k, v) in &self.fields {
100            let entry_size: u32 = 1u32 + ::buffa::types::string_encoded_len(k) as u32
101                + 1u32
102                + {
103                    let __slot = __cache.reserve();
104                    let inner = v.compute_size(__cache);
105                    __cache.set(__slot, inner);
106                    ::buffa::encoding::varint_len(inner as u64) as u32 + inner
107                };
108            size
109                += 1u32 + ::buffa::encoding::varint_len(entry_size as u64) as u32
110                    + entry_size;
111        }
112        size += self.__buffa_unknown_fields.encoded_len() as u32;
113        size
114    }
115    fn write_to(
116        &self,
117        __cache: &mut ::buffa::SizeCache,
118        buf: &mut impl ::buffa::bytes::BufMut,
119    ) {
120        #[allow(unused_imports)]
121        use ::buffa::Enumeration as _;
122        for (k, v) in &self.fields {
123            let __v_len = __cache.consume_next();
124            let entry_size: u32 = 1u32 + ::buffa::types::string_encoded_len(k) as u32
125                + 1u32
126                + (::buffa::encoding::varint_len(__v_len as u64) as u32 + __v_len);
127            ::buffa::encoding::Tag::new(
128                    1u32,
129                    ::buffa::encoding::WireType::LengthDelimited,
130                )
131                .encode(buf);
132            ::buffa::encoding::encode_varint(entry_size as u64, buf);
133            ::buffa::encoding::Tag::new(
134                    1u32,
135                    ::buffa::encoding::WireType::LengthDelimited,
136                )
137                .encode(buf);
138            ::buffa::types::encode_string(k, buf);
139            ::buffa::encoding::Tag::new(
140                    2u32,
141                    ::buffa::encoding::WireType::LengthDelimited,
142                )
143                .encode(buf);
144            ::buffa::encoding::encode_varint(__v_len as u64, buf);
145            v.write_to(__cache, buf);
146        }
147        self.__buffa_unknown_fields.write_to(buf);
148    }
149    fn merge_field(
150        &mut self,
151        tag: ::buffa::encoding::Tag,
152        buf: &mut impl ::buffa::bytes::Buf,
153        depth: u32,
154    ) -> ::core::result::Result<(), ::buffa::DecodeError> {
155        #[allow(unused_imports)]
156        use ::buffa::bytes::Buf as _;
157        #[allow(unused_imports)]
158        use ::buffa::Enumeration as _;
159        match tag.field_number() {
160            1u32 => {
161                if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
162                    return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
163                        field_number: 1u32,
164                        expected: 2u8,
165                        actual: tag.wire_type() as u8,
166                    });
167                }
168                let entry_len = ::buffa::encoding::decode_varint(buf)?;
169                let entry_len = usize::try_from(entry_len)
170                    .map_err(|_| ::buffa::DecodeError::MessageTooLarge)?;
171                if buf.remaining() < entry_len {
172                    return ::core::result::Result::Err(
173                        ::buffa::DecodeError::UnexpectedEof,
174                    );
175                }
176                let entry_limit = buf.remaining() - entry_len;
177                let mut key = ::core::default::Default::default();
178                let mut val = ::core::default::Default::default();
179                while buf.remaining() > entry_limit {
180                    let entry_tag = ::buffa::encoding::Tag::decode(buf)?;
181                    match entry_tag.field_number() {
182                        1 => {
183                            if entry_tag.wire_type()
184                                != ::buffa::encoding::WireType::LengthDelimited
185                            {
186                                return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
187                                    field_number: entry_tag.field_number(),
188                                    expected: 2u8,
189                                    actual: entry_tag.wire_type() as u8,
190                                });
191                            }
192                            key = ::buffa::types::decode_string(buf)?;
193                        }
194                        2 => {
195                            if entry_tag.wire_type()
196                                != ::buffa::encoding::WireType::LengthDelimited
197                            {
198                                return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
199                                    field_number: entry_tag.field_number(),
200                                    expected: 2u8,
201                                    actual: entry_tag.wire_type() as u8,
202                                });
203                            }
204                            ::buffa::Message::merge_length_delimited(
205                                &mut val,
206                                buf,
207                                depth,
208                            )?;
209                        }
210                        _ => {
211                            ::buffa::encoding::skip_field_depth(entry_tag, buf, depth)?;
212                        }
213                    }
214                }
215                if buf.remaining() != entry_limit {
216                    let remaining = buf.remaining();
217                    if remaining > entry_limit {
218                        buf.advance(remaining - entry_limit);
219                    } else {
220                        return ::core::result::Result::Err(
221                            ::buffa::DecodeError::UnexpectedEof,
222                        );
223                    }
224                }
225                self.fields.insert(key, val);
226            }
227            _ => {
228                self.__buffa_unknown_fields
229                    .push(::buffa::encoding::decode_unknown_field(tag, buf, depth)?);
230            }
231        }
232        ::core::result::Result::Ok(())
233    }
234    fn clear(&mut self) {
235        self.fields.clear();
236        self.__buffa_unknown_fields.clear();
237    }
238}
239impl ::buffa::ExtensionSet for Struct {
240    const PROTO_FQN: &'static str = "google.protobuf.Struct";
241    fn unknown_fields(&self) -> &::buffa::UnknownFields {
242        &self.__buffa_unknown_fields
243    }
244    fn unknown_fields_mut(&mut self) -> &mut ::buffa::UnknownFields {
245        &mut self.__buffa_unknown_fields
246    }
247}
248impl ::buffa::text::TextFormat for Struct {
249    fn encode_text(
250        &self,
251        enc: &mut ::buffa::text::TextEncoder<'_>,
252    ) -> ::core::fmt::Result {
253        #[allow(unused_imports)]
254        use ::buffa::Enumeration as _;
255        for (__k, __v) in &self.fields {
256            enc.write_field_name("fields")?;
257            enc.write_map_entry(|enc| {
258                enc.write_field_name("key")?;
259                enc.write_string(__k)?;
260                enc.write_field_name("value")?;
261                enc.write_message(__v)?;
262                ::core::result::Result::Ok(())
263            })?;
264        }
265        enc.write_unknown_fields(&self.__buffa_unknown_fields)?;
266        ::core::result::Result::Ok(())
267    }
268    fn merge_text(
269        &mut self,
270        dec: &mut ::buffa::text::TextDecoder<'_>,
271    ) -> ::core::result::Result<(), ::buffa::text::ParseError> {
272        #[allow(unused_imports)]
273        use ::buffa::Enumeration as _;
274        while let ::core::option::Option::Some(__name) = dec.read_field_name()? {
275            match __name {
276                "fields" => {
277                    let mut __pairs: ::buffa::alloc::vec::Vec<_> = ::buffa::alloc::vec::Vec::new();
278                    dec.read_repeated_into(
279                        &mut __pairs,
280                        |__d| {
281                            let mut __k = ::core::option::Option::None;
282                            let mut __v = ::core::option::Option::None;
283                            __d.merge_map_entry(|__d| {
284                                while let ::core::option::Option::Some(__n) = __d
285                                    .read_field_name()?
286                                {
287                                    match __n {
288                                        "key" => {
289                                            __k = ::core::option::Option::Some(
290                                                __d.read_string()?.into_owned(),
291                                            );
292                                        }
293                                        "value" => {
294                                            __v = ::core::option::Option::Some({
295                                                let mut __m = ::core::default::Default::default();
296                                                __d.merge_message(&mut __m)?;
297                                                __m
298                                            });
299                                        }
300                                        _ => __d.skip_value()?,
301                                    }
302                                }
303                                ::core::result::Result::Ok(())
304                            })?;
305                            ::core::result::Result::Ok((
306                                __k.unwrap_or_default(),
307                                __v.unwrap_or_default(),
308                            ))
309                        },
310                    )?;
311                    for (__k, __v) in __pairs {
312                        self.fields.insert(__k, __v);
313                    }
314                }
315                _ => dec.skip_value()?,
316            }
317        }
318        ::core::result::Result::Ok(())
319    }
320}
321#[doc(hidden)]
322pub const __STRUCT_TEXT_ANY: ::buffa::type_registry::TextAnyEntry = ::buffa::type_registry::TextAnyEntry {
323    type_url: "type.googleapis.com/google.protobuf.Struct",
324    text_encode: ::buffa::type_registry::any_encode_text::<Struct>,
325    text_merge: ::buffa::type_registry::any_merge_text::<Struct>,
326};
327/// `Value` represents a dynamically typed value which can be either
328/// null, a number, a string, a boolean, a recursive struct value, or a
329/// list of values. A producer of value is expected to set one of these
330/// variants. Absence of any variant indicates an error.
331///
332/// The JSON representation for `Value` is JSON value.
333#[derive(Clone, PartialEq, Default)]
334#[cfg_attr(feature = "arbitrary", derive(::arbitrary::Arbitrary))]
335pub struct Value {
336    pub kind: ::core::option::Option<__buffa::oneof::value::Kind>,
337    #[doc(hidden)]
338    pub __buffa_unknown_fields: ::buffa::UnknownFields,
339}
340impl ::core::fmt::Debug for Value {
341    fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
342        f.debug_struct("Value").field("kind", &self.kind).finish()
343    }
344}
345impl Value {
346    /// Protobuf type URL for this message, for use with `Any::pack` and
347    /// `Any::unpack_if`.
348    ///
349    /// Format: `type.googleapis.com/<fully.qualified.TypeName>`
350    pub const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.Value";
351}
352impl ::buffa::DefaultInstance for Value {
353    fn default_instance() -> &'static Self {
354        static VALUE: ::buffa::__private::OnceBox<Value> = ::buffa::__private::OnceBox::new();
355        VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default()))
356    }
357}
358impl ::buffa::MessageName for Value {
359    const PACKAGE: &'static str = "google.protobuf";
360    const NAME: &'static str = "Value";
361    const FULL_NAME: &'static str = "google.protobuf.Value";
362    const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.Value";
363}
364impl ::buffa::Message for Value {
365    /// Returns the total encoded size in bytes.
366    ///
367    /// The result is a `u32`; the protobuf specification requires all
368    /// messages to fit within 2 GiB (2,147,483,647 bytes), so a
369    /// compliant message will never overflow this type.
370    #[allow(clippy::let_and_return)]
371    fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 {
372        #[allow(unused_imports)]
373        use ::buffa::Enumeration as _;
374        let mut size = 0u32;
375        if let ::core::option::Option::Some(ref v) = self.kind {
376            match v {
377                __buffa::oneof::value::Kind::NullValue(x) => {
378                    size += 1u32 + ::buffa::types::int32_encoded_len(x.to_i32()) as u32;
379                }
380                __buffa::oneof::value::Kind::NumberValue(_x) => {
381                    size += 1u32 + ::buffa::types::FIXED64_ENCODED_LEN as u32;
382                }
383                __buffa::oneof::value::Kind::StringValue(x) => {
384                    size += 1u32 + ::buffa::types::string_encoded_len(x) as u32;
385                }
386                __buffa::oneof::value::Kind::BoolValue(_x) => {
387                    size += 1u32 + ::buffa::types::BOOL_ENCODED_LEN as u32;
388                }
389                __buffa::oneof::value::Kind::StructValue(x) => {
390                    let __slot = __cache.reserve();
391                    let inner = x.compute_size(__cache);
392                    __cache.set(__slot, inner);
393                    size
394                        += 1u32 + ::buffa::encoding::varint_len(inner as u64) as u32
395                            + inner;
396                }
397                __buffa::oneof::value::Kind::ListValue(x) => {
398                    let __slot = __cache.reserve();
399                    let inner = x.compute_size(__cache);
400                    __cache.set(__slot, inner);
401                    size
402                        += 1u32 + ::buffa::encoding::varint_len(inner as u64) as u32
403                            + inner;
404                }
405            }
406        }
407        size += self.__buffa_unknown_fields.encoded_len() as u32;
408        size
409    }
410    fn write_to(
411        &self,
412        __cache: &mut ::buffa::SizeCache,
413        buf: &mut impl ::buffa::bytes::BufMut,
414    ) {
415        #[allow(unused_imports)]
416        use ::buffa::Enumeration as _;
417        if let ::core::option::Option::Some(ref v) = self.kind {
418            match v {
419                __buffa::oneof::value::Kind::NullValue(x) => {
420                    ::buffa::encoding::Tag::new(
421                            1u32,
422                            ::buffa::encoding::WireType::Varint,
423                        )
424                        .encode(buf);
425                    ::buffa::types::encode_int32(x.to_i32(), buf);
426                }
427                __buffa::oneof::value::Kind::NumberValue(x) => {
428                    ::buffa::encoding::Tag::new(
429                            2u32,
430                            ::buffa::encoding::WireType::Fixed64,
431                        )
432                        .encode(buf);
433                    ::buffa::types::encode_double(*x, buf);
434                }
435                __buffa::oneof::value::Kind::StringValue(x) => {
436                    ::buffa::encoding::Tag::new(
437                            3u32,
438                            ::buffa::encoding::WireType::LengthDelimited,
439                        )
440                        .encode(buf);
441                    ::buffa::types::encode_string(x, buf);
442                }
443                __buffa::oneof::value::Kind::BoolValue(x) => {
444                    ::buffa::encoding::Tag::new(
445                            4u32,
446                            ::buffa::encoding::WireType::Varint,
447                        )
448                        .encode(buf);
449                    ::buffa::types::encode_bool(*x, buf);
450                }
451                __buffa::oneof::value::Kind::StructValue(x) => {
452                    ::buffa::encoding::Tag::new(
453                            5u32,
454                            ::buffa::encoding::WireType::LengthDelimited,
455                        )
456                        .encode(buf);
457                    ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf);
458                    x.write_to(__cache, buf);
459                }
460                __buffa::oneof::value::Kind::ListValue(x) => {
461                    ::buffa::encoding::Tag::new(
462                            6u32,
463                            ::buffa::encoding::WireType::LengthDelimited,
464                        )
465                        .encode(buf);
466                    ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf);
467                    x.write_to(__cache, buf);
468                }
469            }
470        }
471        self.__buffa_unknown_fields.write_to(buf);
472    }
473    fn merge_field(
474        &mut self,
475        tag: ::buffa::encoding::Tag,
476        buf: &mut impl ::buffa::bytes::Buf,
477        depth: u32,
478    ) -> ::core::result::Result<(), ::buffa::DecodeError> {
479        #[allow(unused_imports)]
480        use ::buffa::bytes::Buf as _;
481        #[allow(unused_imports)]
482        use ::buffa::Enumeration as _;
483        match tag.field_number() {
484            1u32 => {
485                if tag.wire_type() != ::buffa::encoding::WireType::Varint {
486                    return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
487                        field_number: 1u32,
488                        expected: 0u8,
489                        actual: tag.wire_type() as u8,
490                    });
491                }
492                self.kind = ::core::option::Option::Some(
493                    __buffa::oneof::value::Kind::NullValue(
494                        ::buffa::EnumValue::from(::buffa::types::decode_int32(buf)?),
495                    ),
496                );
497            }
498            2u32 => {
499                if tag.wire_type() != ::buffa::encoding::WireType::Fixed64 {
500                    return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
501                        field_number: 2u32,
502                        expected: 1u8,
503                        actual: tag.wire_type() as u8,
504                    });
505                }
506                self.kind = ::core::option::Option::Some(
507                    __buffa::oneof::value::Kind::NumberValue(
508                        ::buffa::types::decode_double(buf)?,
509                    ),
510                );
511            }
512            3u32 => {
513                if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
514                    return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
515                        field_number: 3u32,
516                        expected: 2u8,
517                        actual: tag.wire_type() as u8,
518                    });
519                }
520                self.kind = ::core::option::Option::Some(
521                    __buffa::oneof::value::Kind::StringValue(
522                        ::buffa::types::decode_string(buf)?,
523                    ),
524                );
525            }
526            4u32 => {
527                if tag.wire_type() != ::buffa::encoding::WireType::Varint {
528                    return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
529                        field_number: 4u32,
530                        expected: 0u8,
531                        actual: tag.wire_type() as u8,
532                    });
533                }
534                self.kind = ::core::option::Option::Some(
535                    __buffa::oneof::value::Kind::BoolValue(
536                        ::buffa::types::decode_bool(buf)?,
537                    ),
538                );
539            }
540            5u32 => {
541                if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
542                    return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
543                        field_number: 5u32,
544                        expected: 2u8,
545                        actual: tag.wire_type() as u8,
546                    });
547                }
548                if let ::core::option::Option::Some(
549                    __buffa::oneof::value::Kind::StructValue(ref mut existing),
550                ) = self.kind
551                {
552                    ::buffa::Message::merge_length_delimited(
553                        &mut **existing,
554                        buf,
555                        depth,
556                    )?;
557                } else {
558                    let mut val = ::core::default::Default::default();
559                    ::buffa::Message::merge_length_delimited(&mut val, buf, depth)?;
560                    self.kind = ::core::option::Option::Some(
561                        __buffa::oneof::value::Kind::StructValue(
562                            ::buffa::alloc::boxed::Box::new(val),
563                        ),
564                    );
565                }
566            }
567            6u32 => {
568                if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
569                    return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
570                        field_number: 6u32,
571                        expected: 2u8,
572                        actual: tag.wire_type() as u8,
573                    });
574                }
575                if let ::core::option::Option::Some(
576                    __buffa::oneof::value::Kind::ListValue(ref mut existing),
577                ) = self.kind
578                {
579                    ::buffa::Message::merge_length_delimited(
580                        &mut **existing,
581                        buf,
582                        depth,
583                    )?;
584                } else {
585                    let mut val = ::core::default::Default::default();
586                    ::buffa::Message::merge_length_delimited(&mut val, buf, depth)?;
587                    self.kind = ::core::option::Option::Some(
588                        __buffa::oneof::value::Kind::ListValue(
589                            ::buffa::alloc::boxed::Box::new(val),
590                        ),
591                    );
592                }
593            }
594            _ => {
595                self.__buffa_unknown_fields
596                    .push(::buffa::encoding::decode_unknown_field(tag, buf, depth)?);
597            }
598        }
599        ::core::result::Result::Ok(())
600    }
601    fn clear(&mut self) {
602        self.kind = ::core::option::Option::None;
603        self.__buffa_unknown_fields.clear();
604    }
605}
606impl ::buffa::ExtensionSet for Value {
607    const PROTO_FQN: &'static str = "google.protobuf.Value";
608    fn unknown_fields(&self) -> &::buffa::UnknownFields {
609        &self.__buffa_unknown_fields
610    }
611    fn unknown_fields_mut(&mut self) -> &mut ::buffa::UnknownFields {
612        &mut self.__buffa_unknown_fields
613    }
614}
615impl ::buffa::text::TextFormat for Value {
616    fn encode_text(
617        &self,
618        enc: &mut ::buffa::text::TextEncoder<'_>,
619    ) -> ::core::fmt::Result {
620        #[allow(unused_imports)]
621        use ::buffa::Enumeration as _;
622        if let ::core::option::Option::Some(ref __v) = self.kind {
623            match __v {
624                __buffa::oneof::value::Kind::NullValue(__v) => {
625                    enc.write_field_name("null_value")?;
626                    match __v {
627                        ::buffa::EnumValue::Known(__e) => {
628                            enc.write_enum_name(__e.proto_name())?
629                        }
630                        ::buffa::EnumValue::Unknown(__n) => enc.write_enum_number(*__n)?,
631                    }
632                }
633                __buffa::oneof::value::Kind::NumberValue(__v) => {
634                    enc.write_field_name("number_value")?;
635                    enc.write_f64(*__v)?;
636                }
637                __buffa::oneof::value::Kind::StringValue(__v) => {
638                    enc.write_field_name("string_value")?;
639                    enc.write_string(__v)?;
640                }
641                __buffa::oneof::value::Kind::BoolValue(__v) => {
642                    enc.write_field_name("bool_value")?;
643                    enc.write_bool(*__v)?;
644                }
645                __buffa::oneof::value::Kind::StructValue(__v) => {
646                    enc.write_field_name("struct_value")?;
647                    enc.write_message(&**__v)?;
648                }
649                __buffa::oneof::value::Kind::ListValue(__v) => {
650                    enc.write_field_name("list_value")?;
651                    enc.write_message(&**__v)?;
652                }
653            }
654        }
655        enc.write_unknown_fields(&self.__buffa_unknown_fields)?;
656        ::core::result::Result::Ok(())
657    }
658    fn merge_text(
659        &mut self,
660        dec: &mut ::buffa::text::TextDecoder<'_>,
661    ) -> ::core::result::Result<(), ::buffa::text::ParseError> {
662        #[allow(unused_imports)]
663        use ::buffa::Enumeration as _;
664        while let ::core::option::Option::Some(__name) = dec.read_field_name()? {
665            match __name {
666                "null_value" => {
667                    self.kind = ::core::option::Option::Some(
668                        __buffa::oneof::value::Kind::NullValue(
669                            dec
670                                .read_enum_by_name::<NullValue>()
671                                .map(::buffa::EnumValue::from)?,
672                        ),
673                    );
674                }
675                "number_value" => {
676                    self.kind = ::core::option::Option::Some(
677                        __buffa::oneof::value::Kind::NumberValue(dec.read_f64()?),
678                    );
679                }
680                "string_value" => {
681                    self.kind = ::core::option::Option::Some(
682                        __buffa::oneof::value::Kind::StringValue(
683                            dec.read_string()?.into_owned(),
684                        ),
685                    );
686                }
687                "bool_value" => {
688                    self.kind = ::core::option::Option::Some(
689                        __buffa::oneof::value::Kind::BoolValue(dec.read_bool()?),
690                    );
691                }
692                "struct_value" => {
693                    if let ::core::option::Option::Some(
694                        __buffa::oneof::value::Kind::StructValue(ref mut __existing),
695                    ) = self.kind
696                    {
697                        dec.merge_message(&mut **__existing)?;
698                    } else {
699                        let mut __m = ::core::default::Default::default();
700                        dec.merge_message(&mut __m)?;
701                        self.kind = ::core::option::Option::Some(
702                            __buffa::oneof::value::Kind::StructValue(
703                                ::buffa::alloc::boxed::Box::new(__m),
704                            ),
705                        );
706                    }
707                }
708                "list_value" => {
709                    if let ::core::option::Option::Some(
710                        __buffa::oneof::value::Kind::ListValue(ref mut __existing),
711                    ) = self.kind
712                    {
713                        dec.merge_message(&mut **__existing)?;
714                    } else {
715                        let mut __m = ::core::default::Default::default();
716                        dec.merge_message(&mut __m)?;
717                        self.kind = ::core::option::Option::Some(
718                            __buffa::oneof::value::Kind::ListValue(
719                                ::buffa::alloc::boxed::Box::new(__m),
720                            ),
721                        );
722                    }
723                }
724                _ => dec.skip_value()?,
725            }
726        }
727        ::core::result::Result::Ok(())
728    }
729}
730#[doc(hidden)]
731pub const __VALUE_TEXT_ANY: ::buffa::type_registry::TextAnyEntry = ::buffa::type_registry::TextAnyEntry {
732    type_url: "type.googleapis.com/google.protobuf.Value",
733    text_encode: ::buffa::type_registry::any_encode_text::<Value>,
734    text_merge: ::buffa::type_registry::any_merge_text::<Value>,
735};
736pub mod value {
737    #[allow(unused_imports)]
738    use super::*;
739    #[doc(inline)]
740    pub use super::__buffa::oneof::value::Kind;
741    #[doc(inline)]
742    pub use super::__buffa::view::oneof::value::Kind as KindView;
743}
744/// `ListValue` is a wrapper around a repeated field of values.
745///
746/// The JSON representation for `ListValue` is JSON array.
747#[derive(Clone, PartialEq, Default)]
748#[cfg_attr(feature = "arbitrary", derive(::arbitrary::Arbitrary))]
749pub struct ListValue {
750    /// Repeated field of dynamically typed values.
751    ///
752    /// Field 1: `values`
753    pub values: ::buffa::alloc::vec::Vec<Value>,
754    #[doc(hidden)]
755    pub __buffa_unknown_fields: ::buffa::UnknownFields,
756}
757impl ::core::fmt::Debug for ListValue {
758    fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
759        f.debug_struct("ListValue").field("values", &self.values).finish()
760    }
761}
762impl ListValue {
763    /// Protobuf type URL for this message, for use with `Any::pack` and
764    /// `Any::unpack_if`.
765    ///
766    /// Format: `type.googleapis.com/<fully.qualified.TypeName>`
767    pub const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.ListValue";
768}
769impl ::buffa::DefaultInstance for ListValue {
770    fn default_instance() -> &'static Self {
771        static VALUE: ::buffa::__private::OnceBox<ListValue> = ::buffa::__private::OnceBox::new();
772        VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default()))
773    }
774}
775impl ::buffa::MessageName for ListValue {
776    const PACKAGE: &'static str = "google.protobuf";
777    const NAME: &'static str = "ListValue";
778    const FULL_NAME: &'static str = "google.protobuf.ListValue";
779    const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.ListValue";
780}
781impl ::buffa::Message for ListValue {
782    /// Returns the total encoded size in bytes.
783    ///
784    /// The result is a `u32`; the protobuf specification requires all
785    /// messages to fit within 2 GiB (2,147,483,647 bytes), so a
786    /// compliant message will never overflow this type.
787    #[allow(clippy::let_and_return)]
788    fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 {
789        #[allow(unused_imports)]
790        use ::buffa::Enumeration as _;
791        let mut size = 0u32;
792        for v in &self.values {
793            let __slot = __cache.reserve();
794            let inner_size = v.compute_size(__cache);
795            __cache.set(__slot, inner_size);
796            size
797                += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
798                    + inner_size;
799        }
800        size += self.__buffa_unknown_fields.encoded_len() as u32;
801        size
802    }
803    fn write_to(
804        &self,
805        __cache: &mut ::buffa::SizeCache,
806        buf: &mut impl ::buffa::bytes::BufMut,
807    ) {
808        #[allow(unused_imports)]
809        use ::buffa::Enumeration as _;
810        for v in &self.values {
811            ::buffa::encoding::Tag::new(
812                    1u32,
813                    ::buffa::encoding::WireType::LengthDelimited,
814                )
815                .encode(buf);
816            ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf);
817            v.write_to(__cache, buf);
818        }
819        self.__buffa_unknown_fields.write_to(buf);
820    }
821    fn merge_field(
822        &mut self,
823        tag: ::buffa::encoding::Tag,
824        buf: &mut impl ::buffa::bytes::Buf,
825        depth: u32,
826    ) -> ::core::result::Result<(), ::buffa::DecodeError> {
827        #[allow(unused_imports)]
828        use ::buffa::bytes::Buf as _;
829        #[allow(unused_imports)]
830        use ::buffa::Enumeration as _;
831        match tag.field_number() {
832            1u32 => {
833                if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
834                    return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
835                        field_number: 1u32,
836                        expected: 2u8,
837                        actual: tag.wire_type() as u8,
838                    });
839                }
840                let mut elem = ::core::default::Default::default();
841                ::buffa::Message::merge_length_delimited(&mut elem, buf, depth)?;
842                self.values.push(elem);
843            }
844            _ => {
845                self.__buffa_unknown_fields
846                    .push(::buffa::encoding::decode_unknown_field(tag, buf, depth)?);
847            }
848        }
849        ::core::result::Result::Ok(())
850    }
851    fn clear(&mut self) {
852        self.values.clear();
853        self.__buffa_unknown_fields.clear();
854    }
855}
856impl ::buffa::ExtensionSet for ListValue {
857    const PROTO_FQN: &'static str = "google.protobuf.ListValue";
858    fn unknown_fields(&self) -> &::buffa::UnknownFields {
859        &self.__buffa_unknown_fields
860    }
861    fn unknown_fields_mut(&mut self) -> &mut ::buffa::UnknownFields {
862        &mut self.__buffa_unknown_fields
863    }
864}
865impl ::buffa::text::TextFormat for ListValue {
866    fn encode_text(
867        &self,
868        enc: &mut ::buffa::text::TextEncoder<'_>,
869    ) -> ::core::fmt::Result {
870        #[allow(unused_imports)]
871        use ::buffa::Enumeration as _;
872        for __v in &self.values {
873            enc.write_field_name("values")?;
874            enc.write_message(__v)?;
875        }
876        enc.write_unknown_fields(&self.__buffa_unknown_fields)?;
877        ::core::result::Result::Ok(())
878    }
879    fn merge_text(
880        &mut self,
881        dec: &mut ::buffa::text::TextDecoder<'_>,
882    ) -> ::core::result::Result<(), ::buffa::text::ParseError> {
883        #[allow(unused_imports)]
884        use ::buffa::Enumeration as _;
885        while let ::core::option::Option::Some(__name) = dec.read_field_name()? {
886            match __name {
887                "values" => {
888                    dec.read_repeated_into(
889                        &mut self.values,
890                        |__d| {
891                            let mut __m = ::core::default::Default::default();
892                            __d.merge_message(&mut __m)?;
893                            ::core::result::Result::Ok(__m)
894                        },
895                    )?
896                }
897                _ => dec.skip_value()?,
898            }
899        }
900        ::core::result::Result::Ok(())
901    }
902}
903#[doc(hidden)]
904pub const __LIST_VALUE_TEXT_ANY: ::buffa::type_registry::TextAnyEntry = ::buffa::type_registry::TextAnyEntry {
905    type_url: "type.googleapis.com/google.protobuf.ListValue",
906    text_encode: ::buffa::type_registry::any_encode_text::<ListValue>,
907    text_merge: ::buffa::type_registry::any_merge_text::<ListValue>,
908};