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

/// `Struct` represents a structured data value, consisting of fields
/// which map to dynamically typed values. In some languages, `Struct`
/// might be supported by a native representation. For example, in
/// scripting languages like JS a struct is represented as an
/// object. The details of that representation are described together
/// with the proto support for the language.
///
/// The JSON representation for `Struct` is JSON object.
#[derive(Clone, Debug, Default)]
pub struct StructView<'a> {
    /// Unordered map of dynamically typed values.
    ///
    /// Field 1: `fields` (map)
    pub fields: ::buffa::MapView<
        'a,
        &'a str,
        super::super::__buffa::view::ValueView<'a>,
    >,
    pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
}
impl<'a> StructView<'a> {
    /// Decode from `buf`, enforcing a recursion depth limit for nested messages.
    ///
    /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`]
    /// and by generated sub-message decode arms with `depth - 1`.
    ///
    /// **Not part of the public API.** Named with a leading underscore to
    /// signal that it is for generated-code use only.
    #[doc(hidden)]
    pub fn _decode_depth(
        buf: &'a [u8],
        depth: u32,
    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
        let mut view = Self::default();
        view._merge_into_view(buf, depth)?;
        ::core::result::Result::Ok(view)
    }
    /// Merge fields from `buf` into this view (proto merge semantics).
    ///
    /// Repeated fields append; singular fields last-wins; singular
    /// MESSAGE fields merge recursively. Used by sub-message decode
    /// arms when the same field appears multiple times on the wire.
    ///
    /// **Not part of the public API.**
    #[doc(hidden)]
    pub fn _merge_into_view(
        &mut self,
        buf: &'a [u8],
        depth: u32,
    ) -> ::core::result::Result<(), ::buffa::DecodeError> {
        let _ = depth;
        #[allow(unused_variables)]
        let view = self;
        let mut cur: &'a [u8] = buf;
        while !cur.is_empty() {
            let before_tag = cur;
            let tag = ::buffa::encoding::Tag::decode(&mut cur)?;
            match tag.field_number() {
                1u32 => {
                    if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
                        return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
                            field_number: 1u32,
                            expected: 2u8,
                            actual: tag.wire_type() as u8,
                        });
                    }
                    let entry_bytes = ::buffa::types::borrow_bytes(&mut cur)?;
                    let mut entry_cur: &'a [u8] = entry_bytes;
                    let mut key = "";
                    let mut val = ::core::default::Default::default();
                    while !entry_cur.is_empty() {
                        let entry_tag = ::buffa::encoding::Tag::decode(&mut entry_cur)?;
                        match entry_tag.field_number() {
                            1 => {
                                if entry_tag.wire_type()
                                    != ::buffa::encoding::WireType::LengthDelimited
                                {
                                    return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
                                        field_number: entry_tag.field_number(),
                                        expected: 2u8,
                                        actual: entry_tag.wire_type() as u8,
                                    });
                                }
                                key = ::buffa::types::borrow_str(&mut entry_cur)?;
                            }
                            2 => {
                                if entry_tag.wire_type()
                                    != ::buffa::encoding::WireType::LengthDelimited
                                {
                                    return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
                                        field_number: entry_tag.field_number(),
                                        expected: 2u8,
                                        actual: entry_tag.wire_type() as u8,
                                    });
                                }
                                if depth == 0 {
                                    return Err(::buffa::DecodeError::RecursionLimitExceeded);
                                }
                                let sub = ::buffa::types::borrow_bytes(&mut entry_cur)?;
                                val = super::super::__buffa::view::ValueView::_decode_depth(
                                    sub,
                                    depth - 1,
                                )?;
                            }
                            _ => {
                                ::buffa::encoding::skip_field_depth(
                                    entry_tag,
                                    &mut entry_cur,
                                    depth,
                                )?;
                            }
                        }
                    }
                    view.fields.push(key, val);
                }
                _ => {
                    ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?;
                    let span_len = before_tag.len() - cur.len();
                    view.__buffa_unknown_fields.push_raw(&before_tag[..span_len]);
                }
            }
        }
        ::core::result::Result::Ok(())
    }
}
impl<'a> ::buffa::MessageView<'a> for StructView<'a> {
    type Owned = super::super::Struct;
    fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
        Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT)
    }
    fn decode_view_with_limit(
        buf: &'a [u8],
        depth: u32,
    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
        Self::_decode_depth(buf, depth)
    }
    fn to_owned_message(&self) -> super::super::Struct {
        self.to_owned_from_source(None)
    }
    #[allow(clippy::useless_conversion, clippy::needless_update)]
    fn to_owned_from_source(
        &self,
        __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>,
    ) -> super::super::Struct {
        #[allow(unused_imports)]
        use ::buffa::alloc::string::ToString as _;
        let _ = __buffa_src;
        super::super::Struct {
            fields: self
                .fields
                .iter()
                .map(|(k, v)| (k.to_string(), v.to_owned_from_source(__buffa_src)))
                .collect(),
            __buffa_unknown_fields: self
                .__buffa_unknown_fields
                .to_owned()
                .unwrap_or_default()
                .into(),
            ..::core::default::Default::default()
        }
    }
}
impl<'a> ::buffa::ViewEncode<'a> for StructView<'a> {
    #[allow(clippy::needless_borrow, clippy::let_and_return)]
    fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 {
        #[allow(unused_imports)]
        use ::buffa::Enumeration as _;
        let mut size = 0u32;
        #[allow(clippy::for_kv_map)]
        for (k, v) in &self.fields {
            let entry_size: u32 = 1u32 + ::buffa::types::string_encoded_len(k) as u32
                + 1u32
                + {
                    let __slot = __cache.reserve();
                    let inner = v.compute_size(__cache);
                    __cache.set(__slot, inner);
                    ::buffa::encoding::varint_len(inner as u64) as u32 + inner
                };
            size
                += 1u32 + ::buffa::encoding::varint_len(entry_size as u64) as u32
                    + entry_size;
        }
        size += self.__buffa_unknown_fields.encoded_len() as u32;
        size
    }
    #[allow(clippy::needless_borrow)]
    fn write_to(
        &self,
        __cache: &mut ::buffa::SizeCache,
        buf: &mut impl ::buffa::bytes::BufMut,
    ) {
        #[allow(unused_imports)]
        use ::buffa::Enumeration as _;
        for (k, v) in &self.fields {
            let __v_len = __cache.consume_next();
            let entry_size: u32 = 1u32 + ::buffa::types::string_encoded_len(k) as u32
                + 1u32
                + (::buffa::encoding::varint_len(__v_len as u64) as u32 + __v_len);
            ::buffa::encoding::Tag::new(
                    1u32,
                    ::buffa::encoding::WireType::LengthDelimited,
                )
                .encode(buf);
            ::buffa::encoding::encode_varint(entry_size as u64, buf);
            ::buffa::encoding::Tag::new(
                    1u32,
                    ::buffa::encoding::WireType::LengthDelimited,
                )
                .encode(buf);
            ::buffa::types::encode_string(k, buf);
            ::buffa::encoding::Tag::new(
                    2u32,
                    ::buffa::encoding::WireType::LengthDelimited,
                )
                .encode(buf);
            ::buffa::encoding::encode_varint(__v_len as u64, buf);
            v.write_to(__cache, buf);
        }
        self.__buffa_unknown_fields.write_to(buf);
    }
}
impl<'a> ::buffa::MessageName for StructView<'a> {
    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<'v> ::buffa::DefaultViewInstance for StructView<'v> {
    fn default_view_instance<'a>() -> &'a Self
    where
        Self: 'a,
    {
        static VALUE: ::buffa::__private::OnceBox<StructView<'static>> = ::buffa::__private::OnceBox::new();
        VALUE
            .get_or_init(|| ::buffa::alloc::boxed::Box::new(
                <StructView<'static>>::default(),
            ))
    }
}
impl ::buffa::ViewReborrow for StructView<'static> {
    type Reborrowed<'b> = StructView<'b>;
    fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> {
        this
    }
}
/** Self-contained, `'static` owned view of a `Struct` message.

 Wraps [`::buffa::OwnedView`]`<`[`StructView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required.

 Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`StructView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/
#[derive(Clone, Debug)]
pub struct StructOwnedView(::buffa::OwnedView<StructView<'static>>);
impl StructOwnedView {
    /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer.
    ///
    /// The view borrows directly from the buffer's data; the buffer is
    /// retained inside the returned handle.
    ///
    /// # Errors
    ///
    /// Returns [`::buffa::DecodeError`] if the buffer contains invalid
    /// protobuf data.
    pub fn decode(
        bytes: ::buffa::bytes::Bytes,
    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
        ::core::result::Result::Ok(StructOwnedView(::buffa::OwnedView::decode(bytes)?))
    }
    /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit,
    /// max message size).
    ///
    /// # Errors
    ///
    /// Returns [`::buffa::DecodeError`] if the buffer is invalid or
    /// exceeds the configured limits.
    pub fn decode_with_options(
        bytes: ::buffa::bytes::Bytes,
        opts: &::buffa::DecodeOptions,
    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
        ::core::result::Result::Ok(
            StructOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?),
        )
    }
    /// Build from an owned message via an encode → decode round-trip.
    ///
    /// # Errors
    ///
    /// Returns [`::buffa::DecodeError`] if the re-encoded bytes are
    /// somehow invalid (should not happen for well-formed messages).
    pub fn from_owned(
        msg: &super::super::Struct,
    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
        ::core::result::Result::Ok(StructOwnedView(::buffa::OwnedView::from_owned(msg)?))
    }
    /// Borrow the full [`StructView`] with its lifetime tied to `&self`.
    #[must_use]
    pub fn view(&self) -> &StructView<'_> {
        self.0.reborrow()
    }
    /// Convert to the owned message type.
    #[must_use]
    pub fn to_owned_message(&self) -> super::super::Struct {
        self.0.to_owned_message()
    }
    /// The underlying bytes buffer.
    #[must_use]
    pub fn bytes(&self) -> &::buffa::bytes::Bytes {
        self.0.bytes()
    }
    /// Consume the handle, returning the underlying bytes buffer.
    #[must_use]
    pub fn into_bytes(self) -> ::buffa::bytes::Bytes {
        self.0.into_bytes()
    }
    /// Unordered map of dynamically typed values.
    ///
    /// Field 1: `fields` (map)
    #[must_use]
    pub fn fields(
        &self,
    ) -> &::buffa::MapView<'_, &'_ str, super::super::__buffa::view::ValueView<'_>> {
        &self.0.reborrow().fields
    }
}
impl ::core::convert::From<::buffa::OwnedView<StructView<'static>>> for StructOwnedView {
    fn from(inner: ::buffa::OwnedView<StructView<'static>>) -> Self {
        StructOwnedView(inner)
    }
}
impl ::core::convert::From<StructOwnedView> for ::buffa::OwnedView<StructView<'static>> {
    fn from(wrapper: StructOwnedView) -> Self {
        wrapper.0
    }
}
impl ::core::convert::AsRef<::buffa::OwnedView<StructView<'static>>>
for StructOwnedView {
    fn as_ref(&self) -> &::buffa::OwnedView<StructView<'static>> {
        &self.0
    }
}
impl ::buffa::HasMessageView for super::super::Struct {
    type View<'a> = StructView<'a>;
    type ViewHandle = StructOwnedView;
}
#[cfg(feature = "reflect")]
const _: () = {
    impl<'a> ::buffa_descriptor::reflect::ReflectMessage for StructView<'a> {
        fn message_descriptor(&self) -> &::buffa_descriptor::MessageDescriptor {
            super::super::__buffa::reflect::descriptor_pool()
                .message(Self::__buffa_reflect_message_index())
        }
        fn pool(
            &self,
        ) -> &::buffa::alloc::sync::Arc<::buffa_descriptor::DescriptorPool> {
            super::super::__buffa::reflect::descriptor_pool()
        }
        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 view's reflect get()",
                        field.number(),
                    );
                    ::buffa_descriptor::reflect::ValueRef::Bool(false)
                }
            }
        }
        fn has(&self, field: &::buffa_descriptor::FieldDescriptor) -> bool {
            match field.number() {
                1u32 => !::buffa::MapView::is_empty(&self.fields),
                _ => 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 {
            let bytes = ::buffa::ViewEncode::encode_to_vec(self);
            ::buffa_descriptor::reflect::DynamicMessage::decode(
                    ::buffa::alloc::sync::Arc::clone(
                        super::super::__buffa::reflect::descriptor_pool(),
                    ),
                    Self::__buffa_reflect_message_index(),
                    &bytes,
                )
                .expect("view re-encodes to bytes decodable against its own descriptor")
        }
    }
    impl<'a> ::buffa_descriptor::reflect::ReflectElement for StructView<'a> {
        fn as_value_ref(&self) -> ::buffa_descriptor::reflect::ValueRef<'_> {
            ::buffa_descriptor::reflect::ValueRef::Message(
                ::buffa_descriptor::reflect::ReflectCow::Borrowed(self),
            )
        }
    }
    impl<'a> StructView<'a> {
        /// Memoized `MessageIndex` for this view's message type, resolved
        /// once against the package's embedded descriptor pool. An inherent
        /// associated fn (not a free fn) so sibling views in the same module
        /// do not collide.
        #[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(|| {
                    super::super::__buffa::reflect::descriptor_pool()
                        .message_index(<Self as ::buffa::MessageName>::FULL_NAME)
                        .expect(
                            "generated view type is registered in the embedded descriptor pool",
                        )
                })
        }
    }
};
/// `Value` represents a dynamically typed value which can be either
/// null, a number, a string, a boolean, a recursive struct value, or a
/// list of values. A producer of value is expected to set one of these
/// variants. Absence of any variant indicates an error.
///
/// The JSON representation for `Value` is JSON value.
#[derive(Clone, Debug, Default)]
pub struct ValueView<'a> {
    pub kind: ::core::option::Option<
        super::super::__buffa::view::oneof::value::Kind<'a>,
    >,
    pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
}
impl<'a> ValueView<'a> {
    /// Decode from `buf`, enforcing a recursion depth limit for nested messages.
    ///
    /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`]
    /// and by generated sub-message decode arms with `depth - 1`.
    ///
    /// **Not part of the public API.** Named with a leading underscore to
    /// signal that it is for generated-code use only.
    #[doc(hidden)]
    pub fn _decode_depth(
        buf: &'a [u8],
        depth: u32,
    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
        let mut view = Self::default();
        view._merge_into_view(buf, depth)?;
        ::core::result::Result::Ok(view)
    }
    /// Merge fields from `buf` into this view (proto merge semantics).
    ///
    /// Repeated fields append; singular fields last-wins; singular
    /// MESSAGE fields merge recursively. Used by sub-message decode
    /// arms when the same field appears multiple times on the wire.
    ///
    /// **Not part of the public API.**
    #[doc(hidden)]
    pub fn _merge_into_view(
        &mut self,
        buf: &'a [u8],
        depth: u32,
    ) -> ::core::result::Result<(), ::buffa::DecodeError> {
        let _ = depth;
        #[allow(unused_variables)]
        let view = self;
        let mut cur: &'a [u8] = buf;
        while !cur.is_empty() {
            let before_tag = cur;
            let tag = ::buffa::encoding::Tag::decode(&mut cur)?;
            match tag.field_number() {
                1u32 => {
                    if tag.wire_type() != ::buffa::encoding::WireType::Varint {
                        return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
                            field_number: 1u32,
                            expected: 0u8,
                            actual: tag.wire_type() as u8,
                        });
                    }
                    view.kind = Some(
                        super::super::__buffa::view::oneof::value::Kind::NullValue(
                            ::buffa::EnumValue::from(
                                ::buffa::types::decode_int32(&mut cur)?,
                            ),
                        ),
                    );
                }
                2u32 => {
                    if tag.wire_type() != ::buffa::encoding::WireType::Fixed64 {
                        return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
                            field_number: 2u32,
                            expected: 1u8,
                            actual: tag.wire_type() as u8,
                        });
                    }
                    view.kind = Some(
                        super::super::__buffa::view::oneof::value::Kind::NumberValue(
                            ::buffa::types::decode_double(&mut cur)?,
                        ),
                    );
                }
                3u32 => {
                    if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
                        return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
                            field_number: 3u32,
                            expected: 2u8,
                            actual: tag.wire_type() as u8,
                        });
                    }
                    view.kind = Some(
                        super::super::__buffa::view::oneof::value::Kind::StringValue(
                            ::buffa::types::borrow_str(&mut cur)?,
                        ),
                    );
                }
                4u32 => {
                    if tag.wire_type() != ::buffa::encoding::WireType::Varint {
                        return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
                            field_number: 4u32,
                            expected: 0u8,
                            actual: tag.wire_type() as u8,
                        });
                    }
                    view.kind = Some(
                        super::super::__buffa::view::oneof::value::Kind::BoolValue(
                            ::buffa::types::decode_bool(&mut cur)?,
                        ),
                    );
                }
                5u32 => {
                    if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
                        return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
                            field_number: 5u32,
                            expected: 2u8,
                            actual: tag.wire_type() as u8,
                        });
                    }
                    if depth == 0 {
                        return Err(::buffa::DecodeError::RecursionLimitExceeded);
                    }
                    let sub = ::buffa::types::borrow_bytes(&mut cur)?;
                    if let Some(
                        super::super::__buffa::view::oneof::value::Kind::StructValue(
                            ref mut existing,
                        ),
                    ) = view.kind
                    {
                        existing._merge_into_view(sub, depth - 1)?;
                    } else {
                        view.kind = Some(
                            super::super::__buffa::view::oneof::value::Kind::StructValue(
                                ::buffa::alloc::boxed::Box::new(
                                    super::super::__buffa::view::StructView::_decode_depth(
                                        sub,
                                        depth - 1,
                                    )?,
                                ),
                            ),
                        );
                    }
                }
                6u32 => {
                    if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
                        return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
                            field_number: 6u32,
                            expected: 2u8,
                            actual: tag.wire_type() as u8,
                        });
                    }
                    if depth == 0 {
                        return Err(::buffa::DecodeError::RecursionLimitExceeded);
                    }
                    let sub = ::buffa::types::borrow_bytes(&mut cur)?;
                    if let Some(
                        super::super::__buffa::view::oneof::value::Kind::ListValue(
                            ref mut existing,
                        ),
                    ) = view.kind
                    {
                        existing._merge_into_view(sub, depth - 1)?;
                    } else {
                        view.kind = Some(
                            super::super::__buffa::view::oneof::value::Kind::ListValue(
                                ::buffa::alloc::boxed::Box::new(
                                    super::super::__buffa::view::ListValueView::_decode_depth(
                                        sub,
                                        depth - 1,
                                    )?,
                                ),
                            ),
                        );
                    }
                }
                _ => {
                    ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?;
                    let span_len = before_tag.len() - cur.len();
                    view.__buffa_unknown_fields.push_raw(&before_tag[..span_len]);
                }
            }
        }
        ::core::result::Result::Ok(())
    }
}
impl<'a> ::buffa::MessageView<'a> for ValueView<'a> {
    type Owned = super::super::Value;
    fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
        Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT)
    }
    fn decode_view_with_limit(
        buf: &'a [u8],
        depth: u32,
    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
        Self::_decode_depth(buf, depth)
    }
    fn to_owned_message(&self) -> super::super::Value {
        self.to_owned_from_source(None)
    }
    #[allow(clippy::useless_conversion, clippy::needless_update)]
    fn to_owned_from_source(
        &self,
        __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>,
    ) -> super::super::Value {
        #[allow(unused_imports)]
        use ::buffa::alloc::string::ToString as _;
        let _ = __buffa_src;
        super::super::Value {
            kind: self
                .kind
                .as_ref()
                .map(|v| match v {
                    super::super::__buffa::view::oneof::value::Kind::NullValue(v) => {
                        super::super::__buffa::oneof::value::Kind::NullValue(*v)
                    }
                    super::super::__buffa::view::oneof::value::Kind::NumberValue(v) => {
                        super::super::__buffa::oneof::value::Kind::NumberValue(*v)
                    }
                    super::super::__buffa::view::oneof::value::Kind::StringValue(v) => {
                        super::super::__buffa::oneof::value::Kind::StringValue(
                            v.to_string(),
                        )
                    }
                    super::super::__buffa::view::oneof::value::Kind::BoolValue(v) => {
                        super::super::__buffa::oneof::value::Kind::BoolValue(*v)
                    }
                    super::super::__buffa::view::oneof::value::Kind::StructValue(v) => {
                        super::super::__buffa::oneof::value::Kind::StructValue(
                            ::buffa::alloc::boxed::Box::new(
                                v.to_owned_from_source(__buffa_src),
                            ),
                        )
                    }
                    super::super::__buffa::view::oneof::value::Kind::ListValue(v) => {
                        super::super::__buffa::oneof::value::Kind::ListValue(
                            ::buffa::alloc::boxed::Box::new(
                                v.to_owned_from_source(__buffa_src),
                            ),
                        )
                    }
                }),
            __buffa_unknown_fields: self
                .__buffa_unknown_fields
                .to_owned()
                .unwrap_or_default()
                .into(),
            ..::core::default::Default::default()
        }
    }
}
impl<'a> ::buffa::ViewEncode<'a> for ValueView<'a> {
    #[allow(clippy::needless_borrow, clippy::let_and_return)]
    fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 {
        #[allow(unused_imports)]
        use ::buffa::Enumeration as _;
        let mut size = 0u32;
        if let ::core::option::Option::Some(ref v) = self.kind {
            match v {
                super::super::__buffa::view::oneof::value::Kind::NullValue(x) => {
                    size += 1u32 + ::buffa::types::int32_encoded_len(x.to_i32()) as u32;
                }
                super::super::__buffa::view::oneof::value::Kind::NumberValue(_x) => {
                    size += 1u32 + ::buffa::types::FIXED64_ENCODED_LEN as u32;
                }
                super::super::__buffa::view::oneof::value::Kind::StringValue(x) => {
                    size += 1u32 + ::buffa::types::string_encoded_len(x) as u32;
                }
                super::super::__buffa::view::oneof::value::Kind::BoolValue(_x) => {
                    size += 1u32 + ::buffa::types::BOOL_ENCODED_LEN as u32;
                }
                super::super::__buffa::view::oneof::value::Kind::StructValue(x) => {
                    let __slot = __cache.reserve();
                    let inner = x.compute_size(__cache);
                    __cache.set(__slot, inner);
                    size
                        += 1u32 + ::buffa::encoding::varint_len(inner as u64) as u32
                            + inner;
                }
                super::super::__buffa::view::oneof::value::Kind::ListValue(x) => {
                    let __slot = __cache.reserve();
                    let inner = x.compute_size(__cache);
                    __cache.set(__slot, inner);
                    size
                        += 1u32 + ::buffa::encoding::varint_len(inner as u64) as u32
                            + inner;
                }
            }
        }
        size += self.__buffa_unknown_fields.encoded_len() as u32;
        size
    }
    #[allow(clippy::needless_borrow)]
    fn write_to(
        &self,
        __cache: &mut ::buffa::SizeCache,
        buf: &mut impl ::buffa::bytes::BufMut,
    ) {
        #[allow(unused_imports)]
        use ::buffa::Enumeration as _;
        if let ::core::option::Option::Some(ref v) = self.kind {
            match v {
                super::super::__buffa::view::oneof::value::Kind::NullValue(x) => {
                    ::buffa::encoding::Tag::new(
                            1u32,
                            ::buffa::encoding::WireType::Varint,
                        )
                        .encode(buf);
                    ::buffa::types::encode_int32(x.to_i32(), buf);
                }
                super::super::__buffa::view::oneof::value::Kind::NumberValue(x) => {
                    ::buffa::encoding::Tag::new(
                            2u32,
                            ::buffa::encoding::WireType::Fixed64,
                        )
                        .encode(buf);
                    ::buffa::types::encode_double(*x, buf);
                }
                super::super::__buffa::view::oneof::value::Kind::StringValue(x) => {
                    ::buffa::encoding::Tag::new(
                            3u32,
                            ::buffa::encoding::WireType::LengthDelimited,
                        )
                        .encode(buf);
                    ::buffa::types::encode_string(x, buf);
                }
                super::super::__buffa::view::oneof::value::Kind::BoolValue(x) => {
                    ::buffa::encoding::Tag::new(
                            4u32,
                            ::buffa::encoding::WireType::Varint,
                        )
                        .encode(buf);
                    ::buffa::types::encode_bool(*x, buf);
                }
                super::super::__buffa::view::oneof::value::Kind::StructValue(x) => {
                    ::buffa::encoding::Tag::new(
                            5u32,
                            ::buffa::encoding::WireType::LengthDelimited,
                        )
                        .encode(buf);
                    ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf);
                    x.write_to(__cache, buf);
                }
                super::super::__buffa::view::oneof::value::Kind::ListValue(x) => {
                    ::buffa::encoding::Tag::new(
                            6u32,
                            ::buffa::encoding::WireType::LengthDelimited,
                        )
                        .encode(buf);
                    ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf);
                    x.write_to(__cache, buf);
                }
            }
        }
        self.__buffa_unknown_fields.write_to(buf);
    }
}
impl<'a> ::buffa::MessageName for ValueView<'a> {
    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<'v> ::buffa::DefaultViewInstance for ValueView<'v> {
    fn default_view_instance<'a>() -> &'a Self
    where
        Self: 'a,
    {
        static VALUE: ::buffa::__private::OnceBox<ValueView<'static>> = ::buffa::__private::OnceBox::new();
        VALUE
            .get_or_init(|| ::buffa::alloc::boxed::Box::new(
                <ValueView<'static>>::default(),
            ))
    }
}
impl ::buffa::ViewReborrow for ValueView<'static> {
    type Reborrowed<'b> = ValueView<'b>;
    fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> {
        this
    }
}
/** Self-contained, `'static` owned view of a `Value` message.

 Wraps [`::buffa::OwnedView`]`<`[`ValueView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required.

 Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`ValueView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/
#[derive(Clone, Debug)]
pub struct ValueOwnedView(::buffa::OwnedView<ValueView<'static>>);
impl ValueOwnedView {
    /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer.
    ///
    /// The view borrows directly from the buffer's data; the buffer is
    /// retained inside the returned handle.
    ///
    /// # Errors
    ///
    /// Returns [`::buffa::DecodeError`] if the buffer contains invalid
    /// protobuf data.
    pub fn decode(
        bytes: ::buffa::bytes::Bytes,
    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
        ::core::result::Result::Ok(ValueOwnedView(::buffa::OwnedView::decode(bytes)?))
    }
    /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit,
    /// max message size).
    ///
    /// # Errors
    ///
    /// Returns [`::buffa::DecodeError`] if the buffer is invalid or
    /// exceeds the configured limits.
    pub fn decode_with_options(
        bytes: ::buffa::bytes::Bytes,
        opts: &::buffa::DecodeOptions,
    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
        ::core::result::Result::Ok(
            ValueOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?),
        )
    }
    /// Build from an owned message via an encode → decode round-trip.
    ///
    /// # Errors
    ///
    /// Returns [`::buffa::DecodeError`] if the re-encoded bytes are
    /// somehow invalid (should not happen for well-formed messages).
    pub fn from_owned(
        msg: &super::super::Value,
    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
        ::core::result::Result::Ok(ValueOwnedView(::buffa::OwnedView::from_owned(msg)?))
    }
    /// Borrow the full [`ValueView`] with its lifetime tied to `&self`.
    #[must_use]
    pub fn view(&self) -> &ValueView<'_> {
        self.0.reborrow()
    }
    /// Convert to the owned message type.
    #[must_use]
    pub fn to_owned_message(&self) -> super::super::Value {
        self.0.to_owned_message()
    }
    /// The underlying bytes buffer.
    #[must_use]
    pub fn bytes(&self) -> &::buffa::bytes::Bytes {
        self.0.bytes()
    }
    /// Consume the handle, returning the underlying bytes buffer.
    #[must_use]
    pub fn into_bytes(self) -> ::buffa::bytes::Bytes {
        self.0.into_bytes()
    }
    /// Oneof `kind`.
    #[must_use]
    pub fn kind(
        &self,
    ) -> ::core::option::Option<&super::super::__buffa::view::oneof::value::Kind<'_>> {
        self.0.reborrow().kind.as_ref()
    }
}
impl ::core::convert::From<::buffa::OwnedView<ValueView<'static>>> for ValueOwnedView {
    fn from(inner: ::buffa::OwnedView<ValueView<'static>>) -> Self {
        ValueOwnedView(inner)
    }
}
impl ::core::convert::From<ValueOwnedView> for ::buffa::OwnedView<ValueView<'static>> {
    fn from(wrapper: ValueOwnedView) -> Self {
        wrapper.0
    }
}
impl ::core::convert::AsRef<::buffa::OwnedView<ValueView<'static>>> for ValueOwnedView {
    fn as_ref(&self) -> &::buffa::OwnedView<ValueView<'static>> {
        &self.0
    }
}
impl ::buffa::HasMessageView for super::super::Value {
    type View<'a> = ValueView<'a>;
    type ViewHandle = ValueOwnedView;
}
#[cfg(feature = "reflect")]
const _: () = {
    impl<'a> ::buffa_descriptor::reflect::ReflectMessage for ValueView<'a> {
        fn message_descriptor(&self) -> &::buffa_descriptor::MessageDescriptor {
            super::super::__buffa::reflect::descriptor_pool()
                .message(Self::__buffa_reflect_message_index())
        }
        fn pool(
            &self,
        ) -> &::buffa::alloc::sync::Arc<::buffa_descriptor::DescriptorPool> {
            super::super::__buffa::reflect::descriptor_pool()
        }
        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(
                            super::super::__buffa::view::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(
                            super::super::__buffa::view::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(
                            super::super::__buffa::view::oneof::value::Kind::StringValue(
                                v,
                            ),
                        ) => ::buffa_descriptor::reflect::ValueRef::String(v),
                        _ => ::buffa_descriptor::reflect::ValueRef::String(""),
                    }
                }
                4u32 => {
                    match &self.kind {
                        ::core::option::Option::Some(
                            super::super::__buffa::view::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(
                            super::super::__buffa::view::oneof::value::Kind::StructValue(
                                v,
                            ),
                        ) => {
                            ::buffa_descriptor::reflect::ValueRef::Message(
                                ::buffa_descriptor::reflect::ReflectCow::Borrowed(&**v),
                            )
                        }
                        _ => {
                            ::buffa_descriptor::reflect::ValueRef::Message(
                                ::buffa_descriptor::reflect::ReflectCow::Borrowed(
                                    <super::super::__buffa::view::StructView<
                                        'a,
                                    > as ::buffa::view::DefaultViewInstance>::default_view_instance(),
                                ),
                            )
                        }
                    }
                }
                6u32 => {
                    match &self.kind {
                        ::core::option::Option::Some(
                            super::super::__buffa::view::oneof::value::Kind::ListValue(v),
                        ) => {
                            ::buffa_descriptor::reflect::ValueRef::Message(
                                ::buffa_descriptor::reflect::ReflectCow::Borrowed(&**v),
                            )
                        }
                        _ => {
                            ::buffa_descriptor::reflect::ValueRef::Message(
                                ::buffa_descriptor::reflect::ReflectCow::Borrowed(
                                    <super::super::__buffa::view::ListValueView<
                                        'a,
                                    > as ::buffa::view::DefaultViewInstance>::default_view_instance(),
                                ),
                            )
                        }
                    }
                }
                _ => {
                    ::core::debug_assert!(
                        false,
                        "field number {} is not a member of this view'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(super::super::__buffa::view::oneof::value::Kind::NullValue(_))
                    )
                }
                2u32 => {
                    ::core::matches!(
                        & self.kind,
                        ::core::option::Option::Some(super::super::__buffa::view::oneof::value::Kind::NumberValue(_))
                    )
                }
                3u32 => {
                    ::core::matches!(
                        & self.kind,
                        ::core::option::Option::Some(super::super::__buffa::view::oneof::value::Kind::StringValue(_))
                    )
                }
                4u32 => {
                    ::core::matches!(
                        & self.kind,
                        ::core::option::Option::Some(super::super::__buffa::view::oneof::value::Kind::BoolValue(_))
                    )
                }
                5u32 => {
                    ::core::matches!(
                        & self.kind,
                        ::core::option::Option::Some(super::super::__buffa::view::oneof::value::Kind::StructValue(_))
                    )
                }
                6u32 => {
                    ::core::matches!(
                        & self.kind,
                        ::core::option::Option::Some(super::super::__buffa::view::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 {
            let bytes = ::buffa::ViewEncode::encode_to_vec(self);
            ::buffa_descriptor::reflect::DynamicMessage::decode(
                    ::buffa::alloc::sync::Arc::clone(
                        super::super::__buffa::reflect::descriptor_pool(),
                    ),
                    Self::__buffa_reflect_message_index(),
                    &bytes,
                )
                .expect("view re-encodes to bytes decodable against its own descriptor")
        }
    }
    impl<'a> ::buffa_descriptor::reflect::ReflectElement for ValueView<'a> {
        fn as_value_ref(&self) -> ::buffa_descriptor::reflect::ValueRef<'_> {
            ::buffa_descriptor::reflect::ValueRef::Message(
                ::buffa_descriptor::reflect::ReflectCow::Borrowed(self),
            )
        }
    }
    impl<'a> ValueView<'a> {
        /// Memoized `MessageIndex` for this view's message type, resolved
        /// once against the package's embedded descriptor pool. An inherent
        /// associated fn (not a free fn) so sibling views in the same module
        /// do not collide.
        #[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(|| {
                    super::super::__buffa::reflect::descriptor_pool()
                        .message_index(<Self as ::buffa::MessageName>::FULL_NAME)
                        .expect(
                            "generated view type is registered in the embedded descriptor pool",
                        )
                })
        }
    }
};
/// `ListValue` is a wrapper around a repeated field of values.
///
/// The JSON representation for `ListValue` is JSON array.
#[derive(Clone, Debug, Default)]
pub struct ListValueView<'a> {
    /// Repeated field of dynamically typed values.
    ///
    /// Field 1: `values`
    pub values: ::buffa::RepeatedView<'a, super::super::__buffa::view::ValueView<'a>>,
    pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
}
impl<'a> ListValueView<'a> {
    /// Decode from `buf`, enforcing a recursion depth limit for nested messages.
    ///
    /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`]
    /// and by generated sub-message decode arms with `depth - 1`.
    ///
    /// **Not part of the public API.** Named with a leading underscore to
    /// signal that it is for generated-code use only.
    #[doc(hidden)]
    pub fn _decode_depth(
        buf: &'a [u8],
        depth: u32,
    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
        let mut view = Self::default();
        view._merge_into_view(buf, depth)?;
        ::core::result::Result::Ok(view)
    }
    /// Merge fields from `buf` into this view (proto merge semantics).
    ///
    /// Repeated fields append; singular fields last-wins; singular
    /// MESSAGE fields merge recursively. Used by sub-message decode
    /// arms when the same field appears multiple times on the wire.
    ///
    /// **Not part of the public API.**
    #[doc(hidden)]
    pub fn _merge_into_view(
        &mut self,
        buf: &'a [u8],
        depth: u32,
    ) -> ::core::result::Result<(), ::buffa::DecodeError> {
        let _ = depth;
        #[allow(unused_variables)]
        let view = self;
        let mut cur: &'a [u8] = buf;
        while !cur.is_empty() {
            let before_tag = cur;
            let tag = ::buffa::encoding::Tag::decode(&mut cur)?;
            match tag.field_number() {
                1u32 => {
                    if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
                        return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
                            field_number: 1u32,
                            expected: 2u8,
                            actual: tag.wire_type() as u8,
                        });
                    }
                    if depth == 0 {
                        return Err(::buffa::DecodeError::RecursionLimitExceeded);
                    }
                    let sub = ::buffa::types::borrow_bytes(&mut cur)?;
                    view.values
                        .push(
                            super::super::__buffa::view::ValueView::_decode_depth(
                                sub,
                                depth - 1,
                            )?,
                        );
                }
                _ => {
                    ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?;
                    let span_len = before_tag.len() - cur.len();
                    view.__buffa_unknown_fields.push_raw(&before_tag[..span_len]);
                }
            }
        }
        ::core::result::Result::Ok(())
    }
}
impl<'a> ::buffa::MessageView<'a> for ListValueView<'a> {
    type Owned = super::super::ListValue;
    fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
        Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT)
    }
    fn decode_view_with_limit(
        buf: &'a [u8],
        depth: u32,
    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
        Self::_decode_depth(buf, depth)
    }
    fn to_owned_message(&self) -> super::super::ListValue {
        self.to_owned_from_source(None)
    }
    #[allow(clippy::useless_conversion, clippy::needless_update)]
    fn to_owned_from_source(
        &self,
        __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>,
    ) -> super::super::ListValue {
        #[allow(unused_imports)]
        use ::buffa::alloc::string::ToString as _;
        let _ = __buffa_src;
        super::super::ListValue {
            values: self
                .values
                .iter()
                .map(|v| v.to_owned_from_source(__buffa_src))
                .collect(),
            __buffa_unknown_fields: self
                .__buffa_unknown_fields
                .to_owned()
                .unwrap_or_default()
                .into(),
            ..::core::default::Default::default()
        }
    }
}
impl<'a> ::buffa::ViewEncode<'a> for ListValueView<'a> {
    #[allow(clippy::needless_borrow, clippy::let_and_return)]
    fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 {
        #[allow(unused_imports)]
        use ::buffa::Enumeration as _;
        let mut size = 0u32;
        for v in &self.values {
            let __slot = __cache.reserve();
            let inner_size = v.compute_size(__cache);
            __cache.set(__slot, inner_size);
            size
                += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
                    + inner_size;
        }
        size += self.__buffa_unknown_fields.encoded_len() as u32;
        size
    }
    #[allow(clippy::needless_borrow)]
    fn write_to(
        &self,
        __cache: &mut ::buffa::SizeCache,
        buf: &mut impl ::buffa::bytes::BufMut,
    ) {
        #[allow(unused_imports)]
        use ::buffa::Enumeration as _;
        for v in &self.values {
            ::buffa::encoding::Tag::new(
                    1u32,
                    ::buffa::encoding::WireType::LengthDelimited,
                )
                .encode(buf);
            ::buffa::encoding::encode_varint(__cache.consume_next() as u64, buf);
            v.write_to(__cache, buf);
        }
        self.__buffa_unknown_fields.write_to(buf);
    }
}
impl<'a> ::buffa::MessageName for ListValueView<'a> {
    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<'v> ::buffa::DefaultViewInstance for ListValueView<'v> {
    fn default_view_instance<'a>() -> &'a Self
    where
        Self: 'a,
    {
        static VALUE: ::buffa::__private::OnceBox<ListValueView<'static>> = ::buffa::__private::OnceBox::new();
        VALUE
            .get_or_init(|| ::buffa::alloc::boxed::Box::new(
                <ListValueView<'static>>::default(),
            ))
    }
}
impl ::buffa::ViewReborrow for ListValueView<'static> {
    type Reborrowed<'b> = ListValueView<'b>;
    fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> {
        this
    }
}
/** Self-contained, `'static` owned view of a `ListValue` message.

 Wraps [`::buffa::OwnedView`]`<`[`ListValueView`]`<'static>>`: the decoded view and the [`::buffa::bytes::Bytes`] buffer it borrows from travel together, so the handle is `'static` and `Send + Sync` — suitable for async handlers, spawned tasks, and anywhere a `'static` bound is required.

 Field accessors return borrows tied to `&self`. Use [`Self::view`] to get the full [`ListValueView`] when you need struct patterns, iteration helpers, or to pass the view to lifetime-parameterised code.*/
#[derive(Clone, Debug)]
pub struct ListValueOwnedView(::buffa::OwnedView<ListValueView<'static>>);
impl ListValueOwnedView {
    /// Decode an owned view from a [`::buffa::bytes::Bytes`] buffer.
    ///
    /// The view borrows directly from the buffer's data; the buffer is
    /// retained inside the returned handle.
    ///
    /// # Errors
    ///
    /// Returns [`::buffa::DecodeError`] if the buffer contains invalid
    /// protobuf data.
    pub fn decode(
        bytes: ::buffa::bytes::Bytes,
    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
        ::core::result::Result::Ok(
            ListValueOwnedView(::buffa::OwnedView::decode(bytes)?),
        )
    }
    /// Decode with custom [`::buffa::DecodeOptions`] (recursion limit,
    /// max message size).
    ///
    /// # Errors
    ///
    /// Returns [`::buffa::DecodeError`] if the buffer is invalid or
    /// exceeds the configured limits.
    pub fn decode_with_options(
        bytes: ::buffa::bytes::Bytes,
        opts: &::buffa::DecodeOptions,
    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
        ::core::result::Result::Ok(
            ListValueOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?),
        )
    }
    /// Build from an owned message via an encode → decode round-trip.
    ///
    /// # Errors
    ///
    /// Returns [`::buffa::DecodeError`] if the re-encoded bytes are
    /// somehow invalid (should not happen for well-formed messages).
    pub fn from_owned(
        msg: &super::super::ListValue,
    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
        ::core::result::Result::Ok(
            ListValueOwnedView(::buffa::OwnedView::from_owned(msg)?),
        )
    }
    /// Borrow the full [`ListValueView`] with its lifetime tied to `&self`.
    #[must_use]
    pub fn view(&self) -> &ListValueView<'_> {
        self.0.reborrow()
    }
    /// Convert to the owned message type.
    #[must_use]
    pub fn to_owned_message(&self) -> super::super::ListValue {
        self.0.to_owned_message()
    }
    /// The underlying bytes buffer.
    #[must_use]
    pub fn bytes(&self) -> &::buffa::bytes::Bytes {
        self.0.bytes()
    }
    /// Consume the handle, returning the underlying bytes buffer.
    #[must_use]
    pub fn into_bytes(self) -> ::buffa::bytes::Bytes {
        self.0.into_bytes()
    }
    /// Repeated field of dynamically typed values.
    ///
    /// Field 1: `values`
    #[must_use]
    pub fn values(
        &self,
    ) -> &::buffa::RepeatedView<'_, super::super::__buffa::view::ValueView<'_>> {
        &self.0.reborrow().values
    }
}
impl ::core::convert::From<::buffa::OwnedView<ListValueView<'static>>>
for ListValueOwnedView {
    fn from(inner: ::buffa::OwnedView<ListValueView<'static>>) -> Self {
        ListValueOwnedView(inner)
    }
}
impl ::core::convert::From<ListValueOwnedView>
for ::buffa::OwnedView<ListValueView<'static>> {
    fn from(wrapper: ListValueOwnedView) -> Self {
        wrapper.0
    }
}
impl ::core::convert::AsRef<::buffa::OwnedView<ListValueView<'static>>>
for ListValueOwnedView {
    fn as_ref(&self) -> &::buffa::OwnedView<ListValueView<'static>> {
        &self.0
    }
}
impl ::buffa::HasMessageView for super::super::ListValue {
    type View<'a> = ListValueView<'a>;
    type ViewHandle = ListValueOwnedView;
}
#[cfg(feature = "reflect")]
const _: () = {
    impl<'a> ::buffa_descriptor::reflect::ReflectMessage for ListValueView<'a> {
        fn message_descriptor(&self) -> &::buffa_descriptor::MessageDescriptor {
            super::super::__buffa::reflect::descriptor_pool()
                .message(Self::__buffa_reflect_message_index())
        }
        fn pool(
            &self,
        ) -> &::buffa::alloc::sync::Arc<::buffa_descriptor::DescriptorPool> {
            super::super::__buffa::reflect::descriptor_pool()
        }
        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 view's reflect get()",
                        field.number(),
                    );
                    ::buffa_descriptor::reflect::ValueRef::Bool(false)
                }
            }
        }
        fn has(&self, field: &::buffa_descriptor::FieldDescriptor) -> bool {
            match field.number() {
                1u32 => !::buffa::RepeatedView::is_empty(&self.values),
                _ => 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 {
            let bytes = ::buffa::ViewEncode::encode_to_vec(self);
            ::buffa_descriptor::reflect::DynamicMessage::decode(
                    ::buffa::alloc::sync::Arc::clone(
                        super::super::__buffa::reflect::descriptor_pool(),
                    ),
                    Self::__buffa_reflect_message_index(),
                    &bytes,
                )
                .expect("view re-encodes to bytes decodable against its own descriptor")
        }
    }
    impl<'a> ::buffa_descriptor::reflect::ReflectElement for ListValueView<'a> {
        fn as_value_ref(&self) -> ::buffa_descriptor::reflect::ValueRef<'_> {
            ::buffa_descriptor::reflect::ValueRef::Message(
                ::buffa_descriptor::reflect::ReflectCow::Borrowed(self),
            )
        }
    }
    impl<'a> ListValueView<'a> {
        /// Memoized `MessageIndex` for this view's message type, resolved
        /// once against the package's embedded descriptor pool. An inherent
        /// associated fn (not a free fn) so sibling views in the same module
        /// do not collide.
        #[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(|| {
                    super::super::__buffa::reflect::descriptor_pool()
                        .message_index(<Self as ::buffa::MessageName>::FULL_NAME)
                        .expect(
                            "generated view type is registered in the embedded descriptor pool",
                        )
                })
        }
    }
};
