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

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