// @generated by buffa-codegen. DO NOT EDIT.
// source: google/protobuf/struct.proto

/// `NullValue` is a singleton enumeration to represent the null value for the
/// `Value` type union.
///
/// The JSON representation for `NullValue` is JSON `null`.
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
#[cfg_attr(feature = "arbitrary", derive(::arbitrary::Arbitrary))]
#[repr(i32)]
pub enum NullValue {
    /// Null value.
    NULL_VALUE = 0i32,
}
impl NullValue {
    ///Idiomatic alias for [`Self::NULL_VALUE`]; `Debug` prints the variant name.
    #[allow(non_upper_case_globals)]
    pub const NullValue: Self = Self::NULL_VALUE;
}
impl ::core::default::Default for NullValue {
    fn default() -> Self {
        Self::NULL_VALUE
    }
}
impl ::buffa::Enumeration for NullValue {
    fn from_i32(value: i32) -> ::core::option::Option<Self> {
        match value {
            0i32 => ::core::option::Option::Some(Self::NULL_VALUE),
            _ => ::core::option::Option::None,
        }
    }
    fn to_i32(&self) -> i32 {
        *self as i32
    }
    fn proto_name(&self) -> &'static str {
        match self {
            Self::NULL_VALUE => "NULL_VALUE",
        }
    }
    fn from_proto_name(name: &str) -> ::core::option::Option<Self> {
        match name {
            "NULL_VALUE" => ::core::option::Option::Some(Self::NULL_VALUE),
            _ => ::core::option::Option::None,
        }
    }
    fn values() -> &'static [Self] {
        &[Self::NULL_VALUE]
    }
}
/// `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, PartialEq, Default)]
#[cfg_attr(feature = "arbitrary", derive(::arbitrary::Arbitrary))]
pub struct Struct {
    /// Unordered map of dynamically typed values.
    ///
    /// Field 1: `fields`
    pub fields: ::buffa::__private::HashMap<::buffa::alloc::string::String, Value>,
    #[doc(hidden)]
    pub __buffa_unknown_fields: ::buffa::UnknownFields,
}
impl ::core::fmt::Debug for Struct {
    fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
        f.debug_struct("Struct").field("fields", &self.fields).finish()
    }
}
impl Struct {
    /// Protobuf type URL for this message, for use with `Any::pack` and
    /// `Any::unpack_if`.
    ///
    /// Format: `type.googleapis.com/<fully.qualified.TypeName>`
    pub const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.Struct";
}
impl ::buffa::DefaultInstance for Struct {
    fn default_instance() -> &'static Self {
        static VALUE: ::buffa::__private::OnceBox<Struct> = ::buffa::__private::OnceBox::new();
        VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default()))
    }
}
#[cfg(feature = "reflect")]
const _: () = {
    impl ::buffa_descriptor::reflect::ReflectMessage for Struct {
        fn message_descriptor(&self) -> &::buffa_descriptor::MessageDescriptor {
            __buffa::reflect::descriptor_pool()
                .message(Self::__buffa_reflect_message_index())
        }
        fn pool(
            &self,
        ) -> &::buffa::alloc::sync::Arc<::buffa_descriptor::DescriptorPool> {
            __buffa::reflect::descriptor_pool()
        }
        fn unknown_fields(&self) -> &::buffa::UnknownFields {
            &self.__buffa_unknown_fields
        }
        fn get(
            &self,
            field: &::buffa_descriptor::FieldDescriptor,
        ) -> ::buffa_descriptor::reflect::ValueRef<'_> {
            #[allow(unused_imports)]
            use ::buffa::Enumeration as _;
            match field.number() {
                1u32 => ::buffa_descriptor::reflect::ValueRef::Map(&self.fields),
                _ => {
                    ::core::debug_assert!(
                        false,
                        "field number {} is not a member of this message's reflect get()",
                        field.number(),
                    );
                    ::buffa_descriptor::reflect::ValueRef::Bool(false)
                }
            }
        }
        fn has(&self, field: &::buffa_descriptor::FieldDescriptor) -> bool {
            match field.number() {
                1u32 => !self.fields.is_empty(),
                _ => false,
            }
        }
        fn for_each_set(
            &self,
            f: &mut dyn ::core::ops::FnMut(
                &::buffa_descriptor::FieldDescriptor,
                ::buffa_descriptor::reflect::ValueRef<'_>,
            ),
        ) {
            let md = ::buffa_descriptor::reflect::ReflectMessage::message_descriptor(
                self,
            );
            for fd in md.fields() {
                if ::buffa_descriptor::reflect::ReflectMessage::has(self, fd) {
                    f(fd, ::buffa_descriptor::reflect::ReflectMessage::get(self, fd));
                }
            }
        }
        fn to_dynamic(&self) -> ::buffa_descriptor::reflect::DynamicMessage {
            ::buffa_descriptor::reflect::DynamicMessage::from_message(
                self,
                ::buffa::alloc::sync::Arc::clone(__buffa::reflect::descriptor_pool()),
                Self::__buffa_reflect_message_index(),
            )
        }
    }
    impl ::buffa_descriptor::reflect::ReflectElement for Struct {
        #[inline]
        fn as_value_ref(&self) -> ::buffa_descriptor::reflect::ValueRef<'_> {
            ::buffa_descriptor::reflect::ValueRef::Message(
                ::buffa_descriptor::reflect::ReflectCow::Borrowed(self),
            )
        }
    }
    impl Struct {
        /// Memoized `MessageIndex` for this message type, resolved once
        /// against the package's embedded descriptor pool.
        #[doc(hidden)]
        fn __buffa_reflect_message_index() -> ::buffa_descriptor::MessageIndex {
            static IDX: ::std::sync::OnceLock<::buffa_descriptor::MessageIndex> = ::std::sync::OnceLock::new();
            *IDX
                .get_or_init(|| {
                    __buffa::reflect::descriptor_pool()
                        .message_index(<Self as ::buffa::MessageName>::FULL_NAME)
                        .expect(
                            "generated message is registered in the embedded descriptor pool",
                        )
                })
        }
    }
    impl ::buffa_descriptor::reflect::Reflectable for Struct {
        /// Vtable-mode reflective handle: borrows `self` directly. No
        /// encode/decode round-trip and no allocation — the reflective
        /// accessors read this message's fields in place.
        #[inline]
        fn reflect(&self) -> ::buffa_descriptor::reflect::ReflectCow<'_> {
            ::buffa_descriptor::reflect::ReflectCow::Borrowed(self)
        }
    }
};
impl ::buffa::MessageName for Struct {
    const PACKAGE: &'static str = "google.protobuf";
    const NAME: &'static str = "Struct";
    const FULL_NAME: &'static str = "google.protobuf.Struct";
    const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.Struct";
}
impl ::buffa::Message for Struct {
    /// Returns the total encoded size in bytes.
    ///
    /// The result is a `u32`; the protobuf specification requires all
    /// messages to fit within 2 GiB (2,147,483,647 bytes), so a
    /// compliant message will never overflow this type.
    #[allow(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
    }
    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);
    }
    fn merge_field(
        &mut self,
        tag: ::buffa::encoding::Tag,
        buf: &mut impl ::buffa::bytes::Buf,
        depth: u32,
    ) -> ::core::result::Result<(), ::buffa::DecodeError> {
        #[allow(unused_imports)]
        use ::buffa::bytes::Buf as _;
        #[allow(unused_imports)]
        use ::buffa::Enumeration as _;
        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_len = ::buffa::encoding::decode_varint(buf)?;
                let entry_len = usize::try_from(entry_len)
                    .map_err(|_| ::buffa::DecodeError::MessageTooLarge)?;
                if buf.remaining() < entry_len {
                    return ::core::result::Result::Err(
                        ::buffa::DecodeError::UnexpectedEof,
                    );
                }
                let entry_limit = buf.remaining() - entry_len;
                let mut key = ::core::default::Default::default();
                let mut val = ::core::default::Default::default();
                while buf.remaining() > entry_limit {
                    let entry_tag = ::buffa::encoding::Tag::decode(buf)?;
                    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::decode_string(buf)?;
                        }
                        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,
                                });
                            }
                            ::buffa::Message::merge_length_delimited(
                                &mut val,
                                buf,
                                depth,
                            )?;
                        }
                        _ => {
                            ::buffa::encoding::skip_field_depth(entry_tag, buf, depth)?;
                        }
                    }
                }
                if buf.remaining() != entry_limit {
                    let remaining = buf.remaining();
                    if remaining > entry_limit {
                        buf.advance(remaining - entry_limit);
                    } else {
                        return ::core::result::Result::Err(
                            ::buffa::DecodeError::UnexpectedEof,
                        );
                    }
                }
                self.fields.insert(key, val);
            }
            _ => {
                self.__buffa_unknown_fields
                    .push(::buffa::encoding::decode_unknown_field(tag, buf, depth)?);
            }
        }
        ::core::result::Result::Ok(())
    }
    fn clear(&mut self) {
        self.fields.clear();
        self.__buffa_unknown_fields.clear();
    }
}
impl ::buffa::ExtensionSet for Struct {
    const PROTO_FQN: &'static str = "google.protobuf.Struct";
    fn unknown_fields(&self) -> &::buffa::UnknownFields {
        &self.__buffa_unknown_fields
    }
    fn unknown_fields_mut(&mut self) -> &mut ::buffa::UnknownFields {
        &mut self.__buffa_unknown_fields
    }
}
impl ::buffa::text::TextFormat for Struct {
    fn encode_text(
        &self,
        enc: &mut ::buffa::text::TextEncoder<'_>,
    ) -> ::core::fmt::Result {
        #[allow(unused_imports)]
        use ::buffa::Enumeration as _;
        for (__k, __v) in &self.fields {
            enc.write_field_name("fields")?;
            enc.write_map_entry(|enc| {
                enc.write_field_name("key")?;
                enc.write_string(__k)?;
                enc.write_field_name("value")?;
                enc.write_message(__v)?;
                ::core::result::Result::Ok(())
            })?;
        }
        enc.write_unknown_fields(&self.__buffa_unknown_fields)?;
        ::core::result::Result::Ok(())
    }
    fn merge_text(
        &mut self,
        dec: &mut ::buffa::text::TextDecoder<'_>,
    ) -> ::core::result::Result<(), ::buffa::text::ParseError> {
        #[allow(unused_imports)]
        use ::buffa::Enumeration as _;
        while let ::core::option::Option::Some(__name) = dec.read_field_name()? {
            match __name {
                "fields" => {
                    let mut __pairs: ::buffa::alloc::vec::Vec<_> = ::buffa::alloc::vec::Vec::new();
                    dec.read_repeated_into(
                        &mut __pairs,
                        |__d| {
                            let mut __k = ::core::option::Option::None;
                            let mut __v = ::core::option::Option::None;
                            __d.merge_map_entry(|__d| {
                                while let ::core::option::Option::Some(__n) = __d
                                    .read_field_name()?
                                {
                                    match __n {
                                        "key" => {
                                            __k = ::core::option::Option::Some(
                                                __d.read_string()?.into_owned(),
                                            );
                                        }
                                        "value" => {
                                            __v = ::core::option::Option::Some({
                                                let mut __m = ::core::default::Default::default();
                                                __d.merge_message(&mut __m)?;
                                                __m
                                            });
                                        }
                                        _ => __d.skip_value()?,
                                    }
                                }
                                ::core::result::Result::Ok(())
                            })?;
                            ::core::result::Result::Ok((
                                __k.unwrap_or_default(),
                                __v.unwrap_or_default(),
                            ))
                        },
                    )?;
                    for (__k, __v) in __pairs {
                        self.fields.insert(__k, __v);
                    }
                }
                _ => dec.skip_value()?,
            }
        }
        ::core::result::Result::Ok(())
    }
}
#[doc(hidden)]
pub const __STRUCT_TEXT_ANY: ::buffa::type_registry::TextAnyEntry = ::buffa::type_registry::TextAnyEntry {
    type_url: "type.googleapis.com/google.protobuf.Struct",
    text_encode: ::buffa::type_registry::any_encode_text::<Struct>,
    text_merge: ::buffa::type_registry::any_merge_text::<Struct>,
};
/// `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, PartialEq, Default)]
#[cfg_attr(feature = "arbitrary", derive(::arbitrary::Arbitrary))]
pub struct Value {
    pub kind: ::core::option::Option<__buffa::oneof::value::Kind>,
    #[doc(hidden)]
    pub __buffa_unknown_fields: ::buffa::UnknownFields,
}
impl ::core::fmt::Debug for Value {
    fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
        f.debug_struct("Value").field("kind", &self.kind).finish()
    }
}
impl Value {
    /// Protobuf type URL for this message, for use with `Any::pack` and
    /// `Any::unpack_if`.
    ///
    /// Format: `type.googleapis.com/<fully.qualified.TypeName>`
    pub const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.Value";
}
impl ::buffa::DefaultInstance for Value {
    fn default_instance() -> &'static Self {
        static VALUE: ::buffa::__private::OnceBox<Value> = ::buffa::__private::OnceBox::new();
        VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default()))
    }
}
#[cfg(feature = "reflect")]
const _: () = {
    impl ::buffa_descriptor::reflect::ReflectMessage for Value {
        fn message_descriptor(&self) -> &::buffa_descriptor::MessageDescriptor {
            __buffa::reflect::descriptor_pool()
                .message(Self::__buffa_reflect_message_index())
        }
        fn pool(
            &self,
        ) -> &::buffa::alloc::sync::Arc<::buffa_descriptor::DescriptorPool> {
            __buffa::reflect::descriptor_pool()
        }
        fn unknown_fields(&self) -> &::buffa::UnknownFields {
            &self.__buffa_unknown_fields
        }
        fn get(
            &self,
            field: &::buffa_descriptor::FieldDescriptor,
        ) -> ::buffa_descriptor::reflect::ValueRef<'_> {
            #[allow(unused_imports)]
            use ::buffa::Enumeration as _;
            match field.number() {
                1u32 => {
                    match &self.kind {
                        ::core::option::Option::Some(
                            __buffa::oneof::value::Kind::NullValue(v),
                        ) => {
                            ::buffa_descriptor::reflect::ValueRef::EnumNumber(v.to_i32())
                        }
                        _ => ::buffa_descriptor::reflect::ValueRef::EnumNumber(0),
                    }
                }
                2u32 => {
                    match &self.kind {
                        ::core::option::Option::Some(
                            __buffa::oneof::value::Kind::NumberValue(v),
                        ) => ::buffa_descriptor::reflect::ValueRef::F64(*v),
                        _ => ::buffa_descriptor::reflect::ValueRef::F64(0.0),
                    }
                }
                3u32 => {
                    match &self.kind {
                        ::core::option::Option::Some(
                            __buffa::oneof::value::Kind::StringValue(v),
                        ) => ::buffa_descriptor::reflect::ValueRef::String(v),
                        _ => ::buffa_descriptor::reflect::ValueRef::String(""),
                    }
                }
                4u32 => {
                    match &self.kind {
                        ::core::option::Option::Some(
                            __buffa::oneof::value::Kind::BoolValue(v),
                        ) => ::buffa_descriptor::reflect::ValueRef::Bool(*v),
                        _ => ::buffa_descriptor::reflect::ValueRef::Bool(false),
                    }
                }
                5u32 => {
                    match &self.kind {
                        ::core::option::Option::Some(
                            __buffa::oneof::value::Kind::StructValue(v),
                        ) => {
                            ::buffa_descriptor::reflect::ValueRef::Message(
                                ::buffa_descriptor::reflect::Reflectable::reflect(&**v),
                            )
                        }
                        _ => {
                            ::buffa_descriptor::reflect::ValueRef::Message(
                                ::buffa_descriptor::reflect::Reflectable::reflect(
                                    <Struct as ::buffa::DefaultInstance>::default_instance(),
                                ),
                            )
                        }
                    }
                }
                6u32 => {
                    match &self.kind {
                        ::core::option::Option::Some(
                            __buffa::oneof::value::Kind::ListValue(v),
                        ) => {
                            ::buffa_descriptor::reflect::ValueRef::Message(
                                ::buffa_descriptor::reflect::Reflectable::reflect(&**v),
                            )
                        }
                        _ => {
                            ::buffa_descriptor::reflect::ValueRef::Message(
                                ::buffa_descriptor::reflect::Reflectable::reflect(
                                    <ListValue as ::buffa::DefaultInstance>::default_instance(),
                                ),
                            )
                        }
                    }
                }
                _ => {
                    ::core::debug_assert!(
                        false,
                        "field number {} is not a member of this message's reflect get()",
                        field.number(),
                    );
                    ::buffa_descriptor::reflect::ValueRef::Bool(false)
                }
            }
        }
        fn has(&self, field: &::buffa_descriptor::FieldDescriptor) -> bool {
            match field.number() {
                1u32 => {
                    ::core::matches!(
                        & self.kind,
                        ::core::option::Option::Some(__buffa::oneof::value::Kind::NullValue(_))
                    )
                }
                2u32 => {
                    ::core::matches!(
                        & self.kind,
                        ::core::option::Option::Some(__buffa::oneof::value::Kind::NumberValue(_))
                    )
                }
                3u32 => {
                    ::core::matches!(
                        & self.kind,
                        ::core::option::Option::Some(__buffa::oneof::value::Kind::StringValue(_))
                    )
                }
                4u32 => {
                    ::core::matches!(
                        & self.kind,
                        ::core::option::Option::Some(__buffa::oneof::value::Kind::BoolValue(_))
                    )
                }
                5u32 => {
                    ::core::matches!(
                        & self.kind,
                        ::core::option::Option::Some(__buffa::oneof::value::Kind::StructValue(_))
                    )
                }
                6u32 => {
                    ::core::matches!(
                        & self.kind,
                        ::core::option::Option::Some(__buffa::oneof::value::Kind::ListValue(_))
                    )
                }
                _ => false,
            }
        }
        fn for_each_set(
            &self,
            f: &mut dyn ::core::ops::FnMut(
                &::buffa_descriptor::FieldDescriptor,
                ::buffa_descriptor::reflect::ValueRef<'_>,
            ),
        ) {
            let md = ::buffa_descriptor::reflect::ReflectMessage::message_descriptor(
                self,
            );
            for fd in md.fields() {
                if ::buffa_descriptor::reflect::ReflectMessage::has(self, fd) {
                    f(fd, ::buffa_descriptor::reflect::ReflectMessage::get(self, fd));
                }
            }
        }
        fn to_dynamic(&self) -> ::buffa_descriptor::reflect::DynamicMessage {
            ::buffa_descriptor::reflect::DynamicMessage::from_message(
                self,
                ::buffa::alloc::sync::Arc::clone(__buffa::reflect::descriptor_pool()),
                Self::__buffa_reflect_message_index(),
            )
        }
    }
    impl ::buffa_descriptor::reflect::ReflectElement for Value {
        #[inline]
        fn as_value_ref(&self) -> ::buffa_descriptor::reflect::ValueRef<'_> {
            ::buffa_descriptor::reflect::ValueRef::Message(
                ::buffa_descriptor::reflect::ReflectCow::Borrowed(self),
            )
        }
    }
    impl Value {
        /// Memoized `MessageIndex` for this message type, resolved once
        /// against the package's embedded descriptor pool.
        #[doc(hidden)]
        fn __buffa_reflect_message_index() -> ::buffa_descriptor::MessageIndex {
            static IDX: ::std::sync::OnceLock<::buffa_descriptor::MessageIndex> = ::std::sync::OnceLock::new();
            *IDX
                .get_or_init(|| {
                    __buffa::reflect::descriptor_pool()
                        .message_index(<Self as ::buffa::MessageName>::FULL_NAME)
                        .expect(
                            "generated message is registered in the embedded descriptor pool",
                        )
                })
        }
    }
    impl ::buffa_descriptor::reflect::Reflectable for Value {
        /// Vtable-mode reflective handle: borrows `self` directly. No
        /// encode/decode round-trip and no allocation — the reflective
        /// accessors read this message's fields in place.
        #[inline]
        fn reflect(&self) -> ::buffa_descriptor::reflect::ReflectCow<'_> {
            ::buffa_descriptor::reflect::ReflectCow::Borrowed(self)
        }
    }
};
impl ::buffa::MessageName for Value {
    const PACKAGE: &'static str = "google.protobuf";
    const NAME: &'static str = "Value";
    const FULL_NAME: &'static str = "google.protobuf.Value";
    const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.Value";
}
impl ::buffa::Message for Value {
    /// Returns the total encoded size in bytes.
    ///
    /// The result is a `u32`; the protobuf specification requires all
    /// messages to fit within 2 GiB (2,147,483,647 bytes), so a
    /// compliant message will never overflow this type.
    #[allow(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 {
                __buffa::oneof::value::Kind::NullValue(x) => {
                    size += 1u32 + ::buffa::types::int32_encoded_len(x.to_i32()) as u32;
                }
                __buffa::oneof::value::Kind::NumberValue(_x) => {
                    size += 1u32 + ::buffa::types::FIXED64_ENCODED_LEN as u32;
                }
                __buffa::oneof::value::Kind::StringValue(x) => {
                    size += 1u32 + ::buffa::types::string_encoded_len(x) as u32;
                }
                __buffa::oneof::value::Kind::BoolValue(_x) => {
                    size += 1u32 + ::buffa::types::BOOL_ENCODED_LEN as u32;
                }
                __buffa::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;
                }
                __buffa::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
    }
    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 {
                __buffa::oneof::value::Kind::NullValue(x) => {
                    ::buffa::encoding::Tag::new(
                            1u32,
                            ::buffa::encoding::WireType::Varint,
                        )
                        .encode(buf);
                    ::buffa::types::encode_int32(x.to_i32(), buf);
                }
                __buffa::oneof::value::Kind::NumberValue(x) => {
                    ::buffa::encoding::Tag::new(
                            2u32,
                            ::buffa::encoding::WireType::Fixed64,
                        )
                        .encode(buf);
                    ::buffa::types::encode_double(*x, buf);
                }
                __buffa::oneof::value::Kind::StringValue(x) => {
                    ::buffa::encoding::Tag::new(
                            3u32,
                            ::buffa::encoding::WireType::LengthDelimited,
                        )
                        .encode(buf);
                    ::buffa::types::encode_string(x, buf);
                }
                __buffa::oneof::value::Kind::BoolValue(x) => {
                    ::buffa::encoding::Tag::new(
                            4u32,
                            ::buffa::encoding::WireType::Varint,
                        )
                        .encode(buf);
                    ::buffa::types::encode_bool(*x, buf);
                }
                __buffa::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);
                }
                __buffa::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);
    }
    fn merge_field(
        &mut self,
        tag: ::buffa::encoding::Tag,
        buf: &mut impl ::buffa::bytes::Buf,
        depth: u32,
    ) -> ::core::result::Result<(), ::buffa::DecodeError> {
        #[allow(unused_imports)]
        use ::buffa::bytes::Buf as _;
        #[allow(unused_imports)]
        use ::buffa::Enumeration as _;
        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,
                    });
                }
                self.kind = ::core::option::Option::Some(
                    __buffa::oneof::value::Kind::NullValue(
                        ::buffa::EnumValue::from(::buffa::types::decode_int32(buf)?),
                    ),
                );
            }
            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,
                    });
                }
                self.kind = ::core::option::Option::Some(
                    __buffa::oneof::value::Kind::NumberValue(
                        ::buffa::types::decode_double(buf)?,
                    ),
                );
            }
            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,
                    });
                }
                self.kind = ::core::option::Option::Some(
                    __buffa::oneof::value::Kind::StringValue(
                        ::buffa::types::decode_string(buf)?,
                    ),
                );
            }
            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,
                    });
                }
                self.kind = ::core::option::Option::Some(
                    __buffa::oneof::value::Kind::BoolValue(
                        ::buffa::types::decode_bool(buf)?,
                    ),
                );
            }
            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 let ::core::option::Option::Some(
                    __buffa::oneof::value::Kind::StructValue(ref mut existing),
                ) = self.kind
                {
                    ::buffa::Message::merge_length_delimited(
                        &mut **existing,
                        buf,
                        depth,
                    )?;
                } else {
                    let mut val = ::core::default::Default::default();
                    ::buffa::Message::merge_length_delimited(&mut val, buf, depth)?;
                    self.kind = ::core::option::Option::Some(
                        __buffa::oneof::value::Kind::StructValue(
                            ::buffa::alloc::boxed::Box::new(val),
                        ),
                    );
                }
            }
            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 let ::core::option::Option::Some(
                    __buffa::oneof::value::Kind::ListValue(ref mut existing),
                ) = self.kind
                {
                    ::buffa::Message::merge_length_delimited(
                        &mut **existing,
                        buf,
                        depth,
                    )?;
                } else {
                    let mut val = ::core::default::Default::default();
                    ::buffa::Message::merge_length_delimited(&mut val, buf, depth)?;
                    self.kind = ::core::option::Option::Some(
                        __buffa::oneof::value::Kind::ListValue(
                            ::buffa::alloc::boxed::Box::new(val),
                        ),
                    );
                }
            }
            _ => {
                self.__buffa_unknown_fields
                    .push(::buffa::encoding::decode_unknown_field(tag, buf, depth)?);
            }
        }
        ::core::result::Result::Ok(())
    }
    fn clear(&mut self) {
        self.kind = ::core::option::Option::None;
        self.__buffa_unknown_fields.clear();
    }
}
impl ::buffa::ExtensionSet for Value {
    const PROTO_FQN: &'static str = "google.protobuf.Value";
    fn unknown_fields(&self) -> &::buffa::UnknownFields {
        &self.__buffa_unknown_fields
    }
    fn unknown_fields_mut(&mut self) -> &mut ::buffa::UnknownFields {
        &mut self.__buffa_unknown_fields
    }
}
impl ::buffa::text::TextFormat for Value {
    fn encode_text(
        &self,
        enc: &mut ::buffa::text::TextEncoder<'_>,
    ) -> ::core::fmt::Result {
        #[allow(unused_imports)]
        use ::buffa::Enumeration as _;
        if let ::core::option::Option::Some(ref __v) = self.kind {
            match __v {
                __buffa::oneof::value::Kind::NullValue(__v) => {
                    enc.write_field_name("null_value")?;
                    match __v {
                        ::buffa::EnumValue::Known(__e) => {
                            enc.write_enum_name(__e.proto_name())?
                        }
                        ::buffa::EnumValue::Unknown(__n) => enc.write_enum_number(*__n)?,
                    }
                }
                __buffa::oneof::value::Kind::NumberValue(__v) => {
                    enc.write_field_name("number_value")?;
                    enc.write_f64(*__v)?;
                }
                __buffa::oneof::value::Kind::StringValue(__v) => {
                    enc.write_field_name("string_value")?;
                    enc.write_string(__v)?;
                }
                __buffa::oneof::value::Kind::BoolValue(__v) => {
                    enc.write_field_name("bool_value")?;
                    enc.write_bool(*__v)?;
                }
                __buffa::oneof::value::Kind::StructValue(__v) => {
                    enc.write_field_name("struct_value")?;
                    enc.write_message(&**__v)?;
                }
                __buffa::oneof::value::Kind::ListValue(__v) => {
                    enc.write_field_name("list_value")?;
                    enc.write_message(&**__v)?;
                }
            }
        }
        enc.write_unknown_fields(&self.__buffa_unknown_fields)?;
        ::core::result::Result::Ok(())
    }
    fn merge_text(
        &mut self,
        dec: &mut ::buffa::text::TextDecoder<'_>,
    ) -> ::core::result::Result<(), ::buffa::text::ParseError> {
        #[allow(unused_imports)]
        use ::buffa::Enumeration as _;
        while let ::core::option::Option::Some(__name) = dec.read_field_name()? {
            match __name {
                "null_value" => {
                    self.kind = ::core::option::Option::Some(
                        __buffa::oneof::value::Kind::NullValue(
                            dec
                                .read_enum_by_name::<NullValue>()
                                .map(::buffa::EnumValue::from)?,
                        ),
                    );
                }
                "number_value" => {
                    self.kind = ::core::option::Option::Some(
                        __buffa::oneof::value::Kind::NumberValue(dec.read_f64()?),
                    );
                }
                "string_value" => {
                    self.kind = ::core::option::Option::Some(
                        __buffa::oneof::value::Kind::StringValue(
                            dec.read_string()?.into_owned(),
                        ),
                    );
                }
                "bool_value" => {
                    self.kind = ::core::option::Option::Some(
                        __buffa::oneof::value::Kind::BoolValue(dec.read_bool()?),
                    );
                }
                "struct_value" => {
                    if let ::core::option::Option::Some(
                        __buffa::oneof::value::Kind::StructValue(ref mut __existing),
                    ) = self.kind
                    {
                        dec.merge_message(&mut **__existing)?;
                    } else {
                        let mut __m = ::core::default::Default::default();
                        dec.merge_message(&mut __m)?;
                        self.kind = ::core::option::Option::Some(
                            __buffa::oneof::value::Kind::StructValue(
                                ::buffa::alloc::boxed::Box::new(__m),
                            ),
                        );
                    }
                }
                "list_value" => {
                    if let ::core::option::Option::Some(
                        __buffa::oneof::value::Kind::ListValue(ref mut __existing),
                    ) = self.kind
                    {
                        dec.merge_message(&mut **__existing)?;
                    } else {
                        let mut __m = ::core::default::Default::default();
                        dec.merge_message(&mut __m)?;
                        self.kind = ::core::option::Option::Some(
                            __buffa::oneof::value::Kind::ListValue(
                                ::buffa::alloc::boxed::Box::new(__m),
                            ),
                        );
                    }
                }
                _ => dec.skip_value()?,
            }
        }
        ::core::result::Result::Ok(())
    }
}
#[doc(hidden)]
pub const __VALUE_TEXT_ANY: ::buffa::type_registry::TextAnyEntry = ::buffa::type_registry::TextAnyEntry {
    type_url: "type.googleapis.com/google.protobuf.Value",
    text_encode: ::buffa::type_registry::any_encode_text::<Value>,
    text_merge: ::buffa::type_registry::any_merge_text::<Value>,
};
pub mod value {
    #[allow(unused_imports)]
    use super::*;
    #[doc(inline)]
    pub use super::__buffa::oneof::value::Kind;
    #[doc(inline)]
    pub use super::__buffa::view::oneof::value::Kind as KindView;
}
/// `ListValue` is a wrapper around a repeated field of values.
///
/// The JSON representation for `ListValue` is JSON array.
#[derive(Clone, PartialEq, Default)]
#[cfg_attr(feature = "arbitrary", derive(::arbitrary::Arbitrary))]
pub struct ListValue {
    /// Repeated field of dynamically typed values.
    ///
    /// Field 1: `values`
    pub values: ::buffa::alloc::vec::Vec<Value>,
    #[doc(hidden)]
    pub __buffa_unknown_fields: ::buffa::UnknownFields,
}
impl ::core::fmt::Debug for ListValue {
    fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
        f.debug_struct("ListValue").field("values", &self.values).finish()
    }
}
impl ListValue {
    /// Protobuf type URL for this message, for use with `Any::pack` and
    /// `Any::unpack_if`.
    ///
    /// Format: `type.googleapis.com/<fully.qualified.TypeName>`
    pub const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.ListValue";
}
impl ::buffa::DefaultInstance for ListValue {
    fn default_instance() -> &'static Self {
        static VALUE: ::buffa::__private::OnceBox<ListValue> = ::buffa::__private::OnceBox::new();
        VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default()))
    }
}
#[cfg(feature = "reflect")]
const _: () = {
    impl ::buffa_descriptor::reflect::ReflectMessage for ListValue {
        fn message_descriptor(&self) -> &::buffa_descriptor::MessageDescriptor {
            __buffa::reflect::descriptor_pool()
                .message(Self::__buffa_reflect_message_index())
        }
        fn pool(
            &self,
        ) -> &::buffa::alloc::sync::Arc<::buffa_descriptor::DescriptorPool> {
            __buffa::reflect::descriptor_pool()
        }
        fn unknown_fields(&self) -> &::buffa::UnknownFields {
            &self.__buffa_unknown_fields
        }
        fn get(
            &self,
            field: &::buffa_descriptor::FieldDescriptor,
        ) -> ::buffa_descriptor::reflect::ValueRef<'_> {
            #[allow(unused_imports)]
            use ::buffa::Enumeration as _;
            match field.number() {
                1u32 => ::buffa_descriptor::reflect::ValueRef::List(&self.values),
                _ => {
                    ::core::debug_assert!(
                        false,
                        "field number {} is not a member of this message's reflect get()",
                        field.number(),
                    );
                    ::buffa_descriptor::reflect::ValueRef::Bool(false)
                }
            }
        }
        fn has(&self, field: &::buffa_descriptor::FieldDescriptor) -> bool {
            match field.number() {
                1u32 => !self.values.is_empty(),
                _ => false,
            }
        }
        fn for_each_set(
            &self,
            f: &mut dyn ::core::ops::FnMut(
                &::buffa_descriptor::FieldDescriptor,
                ::buffa_descriptor::reflect::ValueRef<'_>,
            ),
        ) {
            let md = ::buffa_descriptor::reflect::ReflectMessage::message_descriptor(
                self,
            );
            for fd in md.fields() {
                if ::buffa_descriptor::reflect::ReflectMessage::has(self, fd) {
                    f(fd, ::buffa_descriptor::reflect::ReflectMessage::get(self, fd));
                }
            }
        }
        fn to_dynamic(&self) -> ::buffa_descriptor::reflect::DynamicMessage {
            ::buffa_descriptor::reflect::DynamicMessage::from_message(
                self,
                ::buffa::alloc::sync::Arc::clone(__buffa::reflect::descriptor_pool()),
                Self::__buffa_reflect_message_index(),
            )
        }
    }
    impl ::buffa_descriptor::reflect::ReflectElement for ListValue {
        #[inline]
        fn as_value_ref(&self) -> ::buffa_descriptor::reflect::ValueRef<'_> {
            ::buffa_descriptor::reflect::ValueRef::Message(
                ::buffa_descriptor::reflect::ReflectCow::Borrowed(self),
            )
        }
    }
    impl ListValue {
        /// Memoized `MessageIndex` for this message type, resolved once
        /// against the package's embedded descriptor pool.
        #[doc(hidden)]
        fn __buffa_reflect_message_index() -> ::buffa_descriptor::MessageIndex {
            static IDX: ::std::sync::OnceLock<::buffa_descriptor::MessageIndex> = ::std::sync::OnceLock::new();
            *IDX
                .get_or_init(|| {
                    __buffa::reflect::descriptor_pool()
                        .message_index(<Self as ::buffa::MessageName>::FULL_NAME)
                        .expect(
                            "generated message is registered in the embedded descriptor pool",
                        )
                })
        }
    }
    impl ::buffa_descriptor::reflect::Reflectable for ListValue {
        /// Vtable-mode reflective handle: borrows `self` directly. No
        /// encode/decode round-trip and no allocation — the reflective
        /// accessors read this message's fields in place.
        #[inline]
        fn reflect(&self) -> ::buffa_descriptor::reflect::ReflectCow<'_> {
            ::buffa_descriptor::reflect::ReflectCow::Borrowed(self)
        }
    }
};
impl ::buffa::MessageName for ListValue {
    const PACKAGE: &'static str = "google.protobuf";
    const NAME: &'static str = "ListValue";
    const FULL_NAME: &'static str = "google.protobuf.ListValue";
    const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.ListValue";
}
impl ::buffa::Message for ListValue {
    /// Returns the total encoded size in bytes.
    ///
    /// The result is a `u32`; the protobuf specification requires all
    /// messages to fit within 2 GiB (2,147,483,647 bytes), so a
    /// compliant message will never overflow this type.
    #[allow(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
    }
    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);
    }
    fn merge_field(
        &mut self,
        tag: ::buffa::encoding::Tag,
        buf: &mut impl ::buffa::bytes::Buf,
        depth: u32,
    ) -> ::core::result::Result<(), ::buffa::DecodeError> {
        #[allow(unused_imports)]
        use ::buffa::bytes::Buf as _;
        #[allow(unused_imports)]
        use ::buffa::Enumeration as _;
        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 mut elem = ::core::default::Default::default();
                ::buffa::Message::merge_length_delimited(&mut elem, buf, depth)?;
                self.values.push(elem);
            }
            _ => {
                self.__buffa_unknown_fields
                    .push(::buffa::encoding::decode_unknown_field(tag, buf, depth)?);
            }
        }
        ::core::result::Result::Ok(())
    }
    fn clear(&mut self) {
        self.values.clear();
        self.__buffa_unknown_fields.clear();
    }
}
impl ::buffa::ExtensionSet for ListValue {
    const PROTO_FQN: &'static str = "google.protobuf.ListValue";
    fn unknown_fields(&self) -> &::buffa::UnknownFields {
        &self.__buffa_unknown_fields
    }
    fn unknown_fields_mut(&mut self) -> &mut ::buffa::UnknownFields {
        &mut self.__buffa_unknown_fields
    }
}
impl ::buffa::text::TextFormat for ListValue {
    fn encode_text(
        &self,
        enc: &mut ::buffa::text::TextEncoder<'_>,
    ) -> ::core::fmt::Result {
        #[allow(unused_imports)]
        use ::buffa::Enumeration as _;
        for __v in &self.values {
            enc.write_field_name("values")?;
            enc.write_message(__v)?;
        }
        enc.write_unknown_fields(&self.__buffa_unknown_fields)?;
        ::core::result::Result::Ok(())
    }
    fn merge_text(
        &mut self,
        dec: &mut ::buffa::text::TextDecoder<'_>,
    ) -> ::core::result::Result<(), ::buffa::text::ParseError> {
        #[allow(unused_imports)]
        use ::buffa::Enumeration as _;
        while let ::core::option::Option::Some(__name) = dec.read_field_name()? {
            match __name {
                "values" => {
                    dec.read_repeated_into(
                        &mut self.values,
                        |__d| {
                            let mut __m = ::core::default::Default::default();
                            __d.merge_message(&mut __m)?;
                            ::core::result::Result::Ok(__m)
                        },
                    )?
                }
                _ => dec.skip_value()?,
            }
        }
        ::core::result::Result::Ok(())
    }
}
#[doc(hidden)]
pub const __LIST_VALUE_TEXT_ANY: ::buffa::type_registry::TextAnyEntry = ::buffa::type_registry::TextAnyEntry {
    type_url: "type.googleapis.com/google.protobuf.ListValue",
    text_encode: ::buffa::type_registry::any_encode_text::<ListValue>,
    text_merge: ::buffa::type_registry::any_merge_text::<ListValue>,
};
