// @generated by protoc-gen-buffa. DO NOT EDIT.
// source: store/v1/common.proto

/// A raw key-value pair shared by store APIs that move complete rows without
/// additional per-entry metadata.
///
/// Keys must be between 0 and 254 bytes (inclusive) anywhere this message is
/// used for ingestion.
#[derive(Clone, PartialEq, Default)]
#[derive(::serde::Serialize, ::serde::Deserialize)]
#[serde(default)]
pub struct KvEntry {
    /// Field 1: `key`
    #[serde(
        rename = "key",
        with = "::buffa::json_helpers::bytes",
        skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_bytes"
    )]
    pub key: ::buffa::alloc::vec::Vec<u8>,
    /// Field 2: `value`
    #[serde(
        rename = "value",
        with = "::buffa::json_helpers::bytes",
        skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_bytes"
    )]
    pub value: ::buffa::alloc::vec::Vec<u8>,
    #[serde(skip)]
    #[doc(hidden)]
    pub __buffa_unknown_fields: ::buffa::UnknownFields,
    #[doc(hidden)]
    #[serde(skip)]
    pub __buffa_cached_size: ::buffa::__private::CachedSize,
}
impl ::core::fmt::Debug for KvEntry {
    fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
        f.debug_struct("KvEntry")
            .field("key", &self.key)
            .field("value", &self.value)
            .finish()
    }
}
impl KvEntry {
    /// Protobuf type URL for this message, for use with `Any::pack` and
    /// `Any::unpack_if`.
    ///
    /// Format: `type.googleapis.com/<fully.qualified.TypeName>`
    pub const TYPE_URL: &'static str = "type.googleapis.com/store.common.v1.KvEntry";
}
unsafe impl ::buffa::DefaultInstance for KvEntry {
    fn default_instance() -> &'static Self {
        static VALUE: ::buffa::__private::OnceBox<KvEntry> = ::buffa::__private::OnceBox::new();
        VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default()))
    }
}
impl ::buffa::Message for KvEntry {
    /// Returns the total encoded size in bytes.
    ///
    /// The result is a `u32`; the protobuf specification requires all
    /// messages to fit within 2 GiB (2,147,483,647 bytes), so a
    /// compliant message will never overflow this type.
    fn compute_size(&self) -> u32 {
        #[allow(unused_imports)]
        use ::buffa::Enumeration as _;
        let mut size = 0u32;
        if !self.key.is_empty() {
            size += 1u32 + ::buffa::types::bytes_encoded_len(&self.key) as u32;
        }
        if !self.value.is_empty() {
            size += 1u32 + ::buffa::types::bytes_encoded_len(&self.value) as u32;
        }
        size += self.__buffa_unknown_fields.encoded_len() as u32;
        self.__buffa_cached_size.set(size);
        size
    }
    fn write_to(&self, buf: &mut impl ::buffa::bytes::BufMut) {
        #[allow(unused_imports)]
        use ::buffa::Enumeration as _;
        if !self.key.is_empty() {
            ::buffa::encoding::Tag::new(
                    1u32,
                    ::buffa::encoding::WireType::LengthDelimited,
                )
                .encode(buf);
            ::buffa::types::encode_bytes(&self.key, buf);
        }
        if !self.value.is_empty() {
            ::buffa::encoding::Tag::new(
                    2u32,
                    ::buffa::encoding::WireType::LengthDelimited,
                )
                .encode(buf);
            ::buffa::types::encode_bytes(&self.value, buf);
        }
        self.__buffa_unknown_fields.write_to(buf);
    }
    fn merge_field(
        &mut self,
        tag: ::buffa::encoding::Tag,
        buf: &mut impl ::buffa::bytes::Buf,
        depth: u32,
    ) -> ::core::result::Result<(), ::buffa::DecodeError> {
        #[allow(unused_imports)]
        use ::buffa::bytes::Buf as _;
        #[allow(unused_imports)]
        use ::buffa::Enumeration as _;
        match tag.field_number() {
            1u32 => {
                if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
                    return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
                        field_number: 1u32,
                        expected: 2u8,
                        actual: tag.wire_type() as u8,
                    });
                }
                ::buffa::types::merge_bytes(&mut self.key, buf)?;
            }
            2u32 => {
                if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
                    return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
                        field_number: 2u32,
                        expected: 2u8,
                        actual: tag.wire_type() as u8,
                    });
                }
                ::buffa::types::merge_bytes(&mut self.value, buf)?;
            }
            _ => {
                self.__buffa_unknown_fields
                    .push(::buffa::encoding::decode_unknown_field(tag, buf, depth)?);
            }
        }
        ::core::result::Result::Ok(())
    }
    fn cached_size(&self) -> u32 {
        self.__buffa_cached_size.get()
    }
    fn clear(&mut self) {
        self.key.clear();
        self.value.clear();
        self.__buffa_unknown_fields.clear();
        self.__buffa_cached_size.set(0);
    }
}
impl ::buffa::ExtensionSet for KvEntry {
    const PROTO_FQN: &'static str = "store.common.v1.KvEntry";
    fn unknown_fields(&self) -> &::buffa::UnknownFields {
        &self.__buffa_unknown_fields
    }
    fn unknown_fields_mut(&mut self) -> &mut ::buffa::UnknownFields {
        &mut self.__buffa_unknown_fields
    }
}
impl ::buffa::json_helpers::ProtoElemJson for KvEntry {
    fn serialize_proto_json<S: ::serde::Serializer>(
        v: &Self,
        s: S,
    ) -> ::core::result::Result<S::Ok, S::Error> {
        ::serde::Serialize::serialize(v, s)
    }
    fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>(
        d: D,
    ) -> ::core::result::Result<Self, D::Error> {
        <Self as ::serde::Deserialize>::deserialize(d)
    }
}
#[doc(hidden)]
pub const __KV_ENTRY_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry {
    type_url: "type.googleapis.com/store.common.v1.KvEntry",
    to_json: ::buffa::type_registry::any_to_json::<KvEntry>,
    from_json: ::buffa::type_registry::any_from_json::<KvEntry>,
    is_wkt: false,
};
/// A raw key-value pair shared by store APIs that move complete rows without
/// additional per-entry metadata.
///
/// Keys must be between 0 and 254 bytes (inclusive) anywhere this message is
/// used for ingestion.
#[derive(Clone, Debug, Default)]
pub struct KvEntryView<'a> {
    /// Field 1: `key`
    pub key: &'a [u8],
    /// Field 2: `value`
    pub value: &'a [u8],
    pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
}
impl<'a> KvEntryView<'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,
                        });
                    }
                    view.key = ::buffa::types::borrow_bytes(&mut cur)?;
                }
                2u32 => {
                    if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
                        return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
                            field_number: 2u32,
                            expected: 2u8,
                            actual: tag.wire_type() as u8,
                        });
                    }
                    view.value = ::buffa::types::borrow_bytes(&mut cur)?;
                }
                _ => {
                    ::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 KvEntryView<'a> {
    type Owned = KvEntry;
    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)]
    fn to_owned_message(&self) -> KvEntry {
        #[allow(unused_imports)]
        use ::buffa::alloc::string::ToString as _;
        KvEntry {
            key: (self.key).to_vec(),
            value: (self.value).to_vec(),
            __buffa_unknown_fields: self
                .__buffa_unknown_fields
                .to_owned()
                .unwrap_or_default()
                .into(),
            ..::core::default::Default::default()
        }
    }
}
unsafe impl ::buffa::DefaultViewInstance for KvEntryView<'static> {
    fn default_view_instance() -> &'static Self {
        static VALUE: ::buffa::__private::OnceBox<KvEntryView<'static>> = ::buffa::__private::OnceBox::new();
        VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default()))
    }
}
unsafe impl<'a> ::buffa::HasDefaultViewInstance for KvEntryView<'a> {
    type Static = KvEntryView<'static>;
}
/// Identifies a subset of keys by their `KeyCodec` family (reserved_bits +
/// prefix) and a byte regex over the payload portion of each key (bytes after
/// the reserved/prefix header). Shared across `store.compact.v1` prune
/// policies, `store.stream.v1` subscriptions, and any future filter-by-key
/// surface so that one domain type is used end-to-end.
///
/// Named capture groups referenced by callers (e.g. `PolicyGroupBy` /
/// `PolicyOrderBy`) must exist in `payload_regex`.
#[derive(Clone, PartialEq, Default)]
#[derive(::serde::Serialize, ::serde::Deserialize)]
#[serde(default)]
pub struct MatchKey {
    /// Number of high bits in the key reserved for internal routing. Together
    /// with `prefix`, this selects the `KeyCodec` family to scan.
    ///
    /// Field 1: `reserved_bits`
    #[serde(
        rename = "reservedBits",
        alias = "reserved_bits",
        with = "::buffa::json_helpers::uint32",
        skip_serializing_if = "::buffa::json_helpers::skip_if::is_zero_u32"
    )]
    pub reserved_bits: u32,
    /// Key family prefix. Combined with `reserved_bits` to derive the scan range
    /// via `KeyCodec::prefix_bounds`.
    ///
    /// Field 2: `prefix`
    #[serde(
        rename = "prefix",
        with = "::buffa::json_helpers::uint32",
        skip_serializing_if = "::buffa::json_helpers::skip_if::is_zero_u32"
    )]
    pub prefix: u32,
    /// Regex applied to the payload portion of each key. Must be non-empty.
    ///
    /// Field 3: `payload_regex`
    #[serde(
        rename = "payloadRegex",
        alias = "payload_regex",
        with = "::buffa::json_helpers::proto_string",
        skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_str"
    )]
    pub payload_regex: ::buffa::alloc::string::String,
    #[serde(skip)]
    #[doc(hidden)]
    pub __buffa_unknown_fields: ::buffa::UnknownFields,
    #[doc(hidden)]
    #[serde(skip)]
    pub __buffa_cached_size: ::buffa::__private::CachedSize,
}
impl ::core::fmt::Debug for MatchKey {
    fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
        f.debug_struct("MatchKey")
            .field("reserved_bits", &self.reserved_bits)
            .field("prefix", &self.prefix)
            .field("payload_regex", &self.payload_regex)
            .finish()
    }
}
impl MatchKey {
    /// Protobuf type URL for this message, for use with `Any::pack` and
    /// `Any::unpack_if`.
    ///
    /// Format: `type.googleapis.com/<fully.qualified.TypeName>`
    pub const TYPE_URL: &'static str = "type.googleapis.com/store.common.v1.MatchKey";
}
unsafe impl ::buffa::DefaultInstance for MatchKey {
    fn default_instance() -> &'static Self {
        static VALUE: ::buffa::__private::OnceBox<MatchKey> = ::buffa::__private::OnceBox::new();
        VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default()))
    }
}
impl ::buffa::Message for MatchKey {
    /// Returns the total encoded size in bytes.
    ///
    /// The result is a `u32`; the protobuf specification requires all
    /// messages to fit within 2 GiB (2,147,483,647 bytes), so a
    /// compliant message will never overflow this type.
    fn compute_size(&self) -> u32 {
        #[allow(unused_imports)]
        use ::buffa::Enumeration as _;
        let mut size = 0u32;
        if self.reserved_bits != 0u32 {
            size += 1u32 + ::buffa::types::uint32_encoded_len(self.reserved_bits) as u32;
        }
        if self.prefix != 0u32 {
            size += 1u32 + ::buffa::types::uint32_encoded_len(self.prefix) as u32;
        }
        if !self.payload_regex.is_empty() {
            size
                += 1u32 + ::buffa::types::string_encoded_len(&self.payload_regex) as u32;
        }
        size += self.__buffa_unknown_fields.encoded_len() as u32;
        self.__buffa_cached_size.set(size);
        size
    }
    fn write_to(&self, buf: &mut impl ::buffa::bytes::BufMut) {
        #[allow(unused_imports)]
        use ::buffa::Enumeration as _;
        if self.reserved_bits != 0u32 {
            ::buffa::encoding::Tag::new(1u32, ::buffa::encoding::WireType::Varint)
                .encode(buf);
            ::buffa::types::encode_uint32(self.reserved_bits, buf);
        }
        if self.prefix != 0u32 {
            ::buffa::encoding::Tag::new(2u32, ::buffa::encoding::WireType::Varint)
                .encode(buf);
            ::buffa::types::encode_uint32(self.prefix, buf);
        }
        if !self.payload_regex.is_empty() {
            ::buffa::encoding::Tag::new(
                    3u32,
                    ::buffa::encoding::WireType::LengthDelimited,
                )
                .encode(buf);
            ::buffa::types::encode_string(&self.payload_regex, buf);
        }
        self.__buffa_unknown_fields.write_to(buf);
    }
    fn merge_field(
        &mut self,
        tag: ::buffa::encoding::Tag,
        buf: &mut impl ::buffa::bytes::Buf,
        depth: u32,
    ) -> ::core::result::Result<(), ::buffa::DecodeError> {
        #[allow(unused_imports)]
        use ::buffa::bytes::Buf as _;
        #[allow(unused_imports)]
        use ::buffa::Enumeration as _;
        match tag.field_number() {
            1u32 => {
                if tag.wire_type() != ::buffa::encoding::WireType::Varint {
                    return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
                        field_number: 1u32,
                        expected: 0u8,
                        actual: tag.wire_type() as u8,
                    });
                }
                self.reserved_bits = ::buffa::types::decode_uint32(buf)?;
            }
            2u32 => {
                if tag.wire_type() != ::buffa::encoding::WireType::Varint {
                    return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
                        field_number: 2u32,
                        expected: 0u8,
                        actual: tag.wire_type() as u8,
                    });
                }
                self.prefix = ::buffa::types::decode_uint32(buf)?;
            }
            3u32 => {
                if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
                    return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
                        field_number: 3u32,
                        expected: 2u8,
                        actual: tag.wire_type() as u8,
                    });
                }
                ::buffa::types::merge_string(&mut self.payload_regex, buf)?;
            }
            _ => {
                self.__buffa_unknown_fields
                    .push(::buffa::encoding::decode_unknown_field(tag, buf, depth)?);
            }
        }
        ::core::result::Result::Ok(())
    }
    fn cached_size(&self) -> u32 {
        self.__buffa_cached_size.get()
    }
    fn clear(&mut self) {
        self.reserved_bits = 0u32;
        self.prefix = 0u32;
        self.payload_regex.clear();
        self.__buffa_unknown_fields.clear();
        self.__buffa_cached_size.set(0);
    }
}
impl ::buffa::ExtensionSet for MatchKey {
    const PROTO_FQN: &'static str = "store.common.v1.MatchKey";
    fn unknown_fields(&self) -> &::buffa::UnknownFields {
        &self.__buffa_unknown_fields
    }
    fn unknown_fields_mut(&mut self) -> &mut ::buffa::UnknownFields {
        &mut self.__buffa_unknown_fields
    }
}
impl ::buffa::json_helpers::ProtoElemJson for MatchKey {
    fn serialize_proto_json<S: ::serde::Serializer>(
        v: &Self,
        s: S,
    ) -> ::core::result::Result<S::Ok, S::Error> {
        ::serde::Serialize::serialize(v, s)
    }
    fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>(
        d: D,
    ) -> ::core::result::Result<Self, D::Error> {
        <Self as ::serde::Deserialize>::deserialize(d)
    }
}
#[doc(hidden)]
pub const __MATCH_KEY_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry {
    type_url: "type.googleapis.com/store.common.v1.MatchKey",
    to_json: ::buffa::type_registry::any_to_json::<MatchKey>,
    from_json: ::buffa::type_registry::any_from_json::<MatchKey>,
    is_wkt: false,
};
/// Identifies a subset of keys by their `KeyCodec` family (reserved_bits +
/// prefix) and a byte regex over the payload portion of each key (bytes after
/// the reserved/prefix header). Shared across `store.compact.v1` prune
/// policies, `store.stream.v1` subscriptions, and any future filter-by-key
/// surface so that one domain type is used end-to-end.
///
/// Named capture groups referenced by callers (e.g. `PolicyGroupBy` /
/// `PolicyOrderBy`) must exist in `payload_regex`.
#[derive(Clone, Debug, Default)]
pub struct MatchKeyView<'a> {
    /// Number of high bits in the key reserved for internal routing. Together
    /// with `prefix`, this selects the `KeyCodec` family to scan.
    ///
    /// Field 1: `reserved_bits`
    pub reserved_bits: u32,
    /// Key family prefix. Combined with `reserved_bits` to derive the scan range
    /// via `KeyCodec::prefix_bounds`.
    ///
    /// Field 2: `prefix`
    pub prefix: u32,
    /// Regex applied to the payload portion of each key. Must be non-empty.
    ///
    /// Field 3: `payload_regex`
    pub payload_regex: &'a str,
    pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
}
impl<'a> MatchKeyView<'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.reserved_bits = ::buffa::types::decode_uint32(&mut cur)?;
                }
                2u32 => {
                    if tag.wire_type() != ::buffa::encoding::WireType::Varint {
                        return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
                            field_number: 2u32,
                            expected: 0u8,
                            actual: tag.wire_type() as u8,
                        });
                    }
                    view.prefix = ::buffa::types::decode_uint32(&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.payload_regex = ::buffa::types::borrow_str(&mut cur)?;
                }
                _ => {
                    ::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 MatchKeyView<'a> {
    type Owned = MatchKey;
    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)]
    fn to_owned_message(&self) -> MatchKey {
        #[allow(unused_imports)]
        use ::buffa::alloc::string::ToString as _;
        MatchKey {
            reserved_bits: self.reserved_bits,
            prefix: self.prefix,
            payload_regex: self.payload_regex.to_string(),
            __buffa_unknown_fields: self
                .__buffa_unknown_fields
                .to_owned()
                .unwrap_or_default()
                .into(),
            ..::core::default::Default::default()
        }
    }
}
unsafe impl ::buffa::DefaultViewInstance for MatchKeyView<'static> {
    fn default_view_instance() -> &'static Self {
        static VALUE: ::buffa::__private::OnceBox<MatchKeyView<'static>> = ::buffa::__private::OnceBox::new();
        VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default()))
    }
}
unsafe impl<'a> ::buffa::HasDefaultViewInstance for MatchKeyView<'a> {
    type Static = MatchKeyView<'static>;
}
/// Matches an uninterpreted byte string by exact value, prefix, or full-string
/// regex. Used for filtering both decoded logical keys and operation values in
/// APIs that operate above the store-row `KeyCodec` layer.
#[derive(Clone, PartialEq, Default)]
#[derive(::serde::Serialize)]
#[serde(default)]
pub struct BytesFilter {
    #[serde(flatten)]
    pub kind: Option<bytes_filter::Kind>,
    #[serde(skip)]
    #[doc(hidden)]
    pub __buffa_unknown_fields: ::buffa::UnknownFields,
    #[doc(hidden)]
    #[serde(skip)]
    pub __buffa_cached_size: ::buffa::__private::CachedSize,
}
impl ::core::fmt::Debug for BytesFilter {
    fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
        f.debug_struct("BytesFilter").field("kind", &self.kind).finish()
    }
}
impl BytesFilter {
    /// Protobuf type URL for this message, for use with `Any::pack` and
    /// `Any::unpack_if`.
    ///
    /// Format: `type.googleapis.com/<fully.qualified.TypeName>`
    pub const TYPE_URL: &'static str = "type.googleapis.com/store.common.v1.BytesFilter";
}
unsafe impl ::buffa::DefaultInstance for BytesFilter {
    fn default_instance() -> &'static Self {
        static VALUE: ::buffa::__private::OnceBox<BytesFilter> = ::buffa::__private::OnceBox::new();
        VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default()))
    }
}
impl ::buffa::Message for BytesFilter {
    /// Returns the total encoded size in bytes.
    ///
    /// The result is a `u32`; the protobuf specification requires all
    /// messages to fit within 2 GiB (2,147,483,647 bytes), so a
    /// compliant message will never overflow this type.
    fn compute_size(&self) -> u32 {
        #[allow(unused_imports)]
        use ::buffa::Enumeration as _;
        let mut size = 0u32;
        if let ::core::option::Option::Some(ref v) = self.kind {
            match v {
                bytes_filter::Kind::Exact(x) => {
                    size += 1u32 + ::buffa::types::bytes_encoded_len(x) as u32;
                }
                bytes_filter::Kind::Prefix(x) => {
                    size += 1u32 + ::buffa::types::bytes_encoded_len(x) as u32;
                }
                bytes_filter::Kind::Regex(x) => {
                    size += 1u32 + ::buffa::types::string_encoded_len(x) as u32;
                }
            }
        }
        size += self.__buffa_unknown_fields.encoded_len() as u32;
        self.__buffa_cached_size.set(size);
        size
    }
    fn write_to(&self, 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 {
                bytes_filter::Kind::Exact(x) => {
                    ::buffa::encoding::Tag::new(
                            1u32,
                            ::buffa::encoding::WireType::LengthDelimited,
                        )
                        .encode(buf);
                    ::buffa::types::encode_bytes(x, buf);
                }
                bytes_filter::Kind::Prefix(x) => {
                    ::buffa::encoding::Tag::new(
                            2u32,
                            ::buffa::encoding::WireType::LengthDelimited,
                        )
                        .encode(buf);
                    ::buffa::types::encode_bytes(x, buf);
                }
                bytes_filter::Kind::Regex(x) => {
                    ::buffa::encoding::Tag::new(
                            3u32,
                            ::buffa::encoding::WireType::LengthDelimited,
                        )
                        .encode(buf);
                    ::buffa::types::encode_string(x, buf);
                }
            }
        }
        self.__buffa_unknown_fields.write_to(buf);
    }
    fn merge_field(
        &mut self,
        tag: ::buffa::encoding::Tag,
        buf: &mut impl ::buffa::bytes::Buf,
        depth: u32,
    ) -> ::core::result::Result<(), ::buffa::DecodeError> {
        #[allow(unused_imports)]
        use ::buffa::bytes::Buf as _;
        #[allow(unused_imports)]
        use ::buffa::Enumeration as _;
        match tag.field_number() {
            1u32 => {
                if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
                    return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
                        field_number: 1u32,
                        expected: 2u8,
                        actual: tag.wire_type() as u8,
                    });
                }
                self.kind = ::core::option::Option::Some(
                    bytes_filter::Kind::Exact(::buffa::types::decode_bytes(buf)?),
                );
            }
            2u32 => {
                if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
                    return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
                        field_number: 2u32,
                        expected: 2u8,
                        actual: tag.wire_type() as u8,
                    });
                }
                self.kind = ::core::option::Option::Some(
                    bytes_filter::Kind::Prefix(::buffa::types::decode_bytes(buf)?),
                );
            }
            3u32 => {
                if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
                    return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
                        field_number: 3u32,
                        expected: 2u8,
                        actual: tag.wire_type() as u8,
                    });
                }
                self.kind = ::core::option::Option::Some(
                    bytes_filter::Kind::Regex(::buffa::types::decode_string(buf)?),
                );
            }
            _ => {
                self.__buffa_unknown_fields
                    .push(::buffa::encoding::decode_unknown_field(tag, buf, depth)?);
            }
        }
        ::core::result::Result::Ok(())
    }
    fn cached_size(&self) -> u32 {
        self.__buffa_cached_size.get()
    }
    fn clear(&mut self) {
        self.kind = ::core::option::Option::None;
        self.__buffa_unknown_fields.clear();
        self.__buffa_cached_size.set(0);
    }
}
impl ::buffa::ExtensionSet for BytesFilter {
    const PROTO_FQN: &'static str = "store.common.v1.BytesFilter";
    fn unknown_fields(&self) -> &::buffa::UnknownFields {
        &self.__buffa_unknown_fields
    }
    fn unknown_fields_mut(&mut self) -> &mut ::buffa::UnknownFields {
        &mut self.__buffa_unknown_fields
    }
}
impl<'de> serde::Deserialize<'de> for BytesFilter {
    fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
        struct _V;
        impl<'de> serde::de::Visitor<'de> for _V {
            type Value = BytesFilter;
            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
                f.write_str("struct BytesFilter")
            }
            #[allow(clippy::field_reassign_with_default)]
            fn visit_map<A: serde::de::MapAccess<'de>>(
                self,
                mut map: A,
            ) -> Result<BytesFilter, A::Error> {
                let mut __oneof_kind: Option<bytes_filter::Kind> = None;
                while let Some(key) = map.next_key::<::buffa::alloc::string::String>()? {
                    match key.as_str() {
                        "exact" => {
                            struct _DeserSeed;
                            impl<'de> serde::de::DeserializeSeed<'de> for _DeserSeed {
                                type Value = ::buffa::alloc::vec::Vec<u8>;
                                fn deserialize<D: serde::Deserializer<'de>>(
                                    self,
                                    d: D,
                                ) -> ::core::result::Result<
                                    ::buffa::alloc::vec::Vec<u8>,
                                    D::Error,
                                > {
                                    ::buffa::json_helpers::bytes::deserialize(d)
                                }
                            }
                            let v: Option<::buffa::alloc::vec::Vec<u8>> = map
                                .next_value_seed(
                                    ::buffa::json_helpers::NullableDeserializeSeed(_DeserSeed),
                                )?;
                            if let Some(v) = v {
                                if __oneof_kind.is_some() {
                                    return Err(
                                        serde::de::Error::custom(
                                            "multiple oneof fields set for 'kind'",
                                        ),
                                    );
                                }
                                __oneof_kind = Some(bytes_filter::Kind::Exact(v));
                            }
                        }
                        "prefix" => {
                            struct _DeserSeed;
                            impl<'de> serde::de::DeserializeSeed<'de> for _DeserSeed {
                                type Value = ::buffa::alloc::vec::Vec<u8>;
                                fn deserialize<D: serde::Deserializer<'de>>(
                                    self,
                                    d: D,
                                ) -> ::core::result::Result<
                                    ::buffa::alloc::vec::Vec<u8>,
                                    D::Error,
                                > {
                                    ::buffa::json_helpers::bytes::deserialize(d)
                                }
                            }
                            let v: Option<::buffa::alloc::vec::Vec<u8>> = map
                                .next_value_seed(
                                    ::buffa::json_helpers::NullableDeserializeSeed(_DeserSeed),
                                )?;
                            if let Some(v) = v {
                                if __oneof_kind.is_some() {
                                    return Err(
                                        serde::de::Error::custom(
                                            "multiple oneof fields set for 'kind'",
                                        ),
                                    );
                                }
                                __oneof_kind = Some(bytes_filter::Kind::Prefix(v));
                            }
                        }
                        "regex" => {
                            let v: Option<::buffa::alloc::string::String> = map
                                .next_value_seed(
                                    ::buffa::json_helpers::NullableDeserializeSeed(
                                        ::buffa::json_helpers::DefaultDeserializeSeed::<
                                            ::buffa::alloc::string::String,
                                        >::new(),
                                    ),
                                )?;
                            if let Some(v) = v {
                                if __oneof_kind.is_some() {
                                    return Err(
                                        serde::de::Error::custom(
                                            "multiple oneof fields set for 'kind'",
                                        ),
                                    );
                                }
                                __oneof_kind = Some(bytes_filter::Kind::Regex(v));
                            }
                        }
                        _ => {
                            map.next_value::<serde::de::IgnoredAny>()?;
                        }
                    }
                }
                let mut __r = <BytesFilter as ::core::default::Default>::default();
                __r.kind = __oneof_kind;
                Ok(__r)
            }
        }
        d.deserialize_map(_V)
    }
}
impl ::buffa::json_helpers::ProtoElemJson for BytesFilter {
    fn serialize_proto_json<S: ::serde::Serializer>(
        v: &Self,
        s: S,
    ) -> ::core::result::Result<S::Ok, S::Error> {
        ::serde::Serialize::serialize(v, s)
    }
    fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>(
        d: D,
    ) -> ::core::result::Result<Self, D::Error> {
        <Self as ::serde::Deserialize>::deserialize(d)
    }
}
#[doc(hidden)]
pub const __BYTES_FILTER_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry {
    type_url: "type.googleapis.com/store.common.v1.BytesFilter",
    to_json: ::buffa::type_registry::any_to_json::<BytesFilter>,
    from_json: ::buffa::type_registry::any_from_json::<BytesFilter>,
    is_wkt: false,
};
/// Matches an uninterpreted byte string by exact value, prefix, or full-string
/// regex. Used for filtering both decoded logical keys and operation values in
/// APIs that operate above the store-row `KeyCodec` layer.
#[derive(Clone, Debug, Default)]
pub struct BytesFilterView<'a> {
    pub kind: ::core::option::Option<bytes_filter::KindView<'a>>,
    pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
}
impl<'a> BytesFilterView<'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,
                        });
                    }
                    view.kind = Some(
                        bytes_filter::KindView::Exact(
                            ::buffa::types::borrow_bytes(&mut cur)?,
                        ),
                    );
                }
                2u32 => {
                    if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
                        return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
                            field_number: 2u32,
                            expected: 2u8,
                            actual: tag.wire_type() as u8,
                        });
                    }
                    view.kind = Some(
                        bytes_filter::KindView::Prefix(
                            ::buffa::types::borrow_bytes(&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(
                        bytes_filter::KindView::Regex(
                            ::buffa::types::borrow_str(&mut cur)?,
                        ),
                    );
                }
                _ => {
                    ::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 BytesFilterView<'a> {
    type Owned = BytesFilter;
    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)]
    fn to_owned_message(&self) -> BytesFilter {
        #[allow(unused_imports)]
        use ::buffa::alloc::string::ToString as _;
        BytesFilter {
            kind: self
                .kind
                .as_ref()
                .map(|v| match v {
                    bytes_filter::KindView::Exact(v) => {
                        bytes_filter::Kind::Exact((v).to_vec())
                    }
                    bytes_filter::KindView::Prefix(v) => {
                        bytes_filter::Kind::Prefix((v).to_vec())
                    }
                    bytes_filter::KindView::Regex(v) => {
                        bytes_filter::Kind::Regex(v.to_string())
                    }
                }),
            __buffa_unknown_fields: self
                .__buffa_unknown_fields
                .to_owned()
                .unwrap_or_default()
                .into(),
            ..::core::default::Default::default()
        }
    }
}
unsafe impl ::buffa::DefaultViewInstance for BytesFilterView<'static> {
    fn default_view_instance() -> &'static Self {
        static VALUE: ::buffa::__private::OnceBox<BytesFilterView<'static>> = ::buffa::__private::OnceBox::new();
        VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default()))
    }
}
unsafe impl<'a> ::buffa::HasDefaultViewInstance for BytesFilterView<'a> {
    type Static = BytesFilterView<'static>;
}
pub mod bytes_filter {
    #[allow(unused_imports)]
    use super::*;
    #[derive(Clone, PartialEq, Debug)]
    pub enum Kind {
        Exact(::buffa::alloc::vec::Vec<u8>),
        Prefix(::buffa::alloc::vec::Vec<u8>),
        Regex(::buffa::alloc::string::String),
    }
    impl ::buffa::Oneof for Kind {}
    impl serde::Serialize for Kind {
        fn serialize<S: serde::Serializer>(
            &self,
            s: S,
        ) -> ::core::result::Result<S::Ok, S::Error> {
            use serde::ser::SerializeMap;
            let mut map = s.serialize_map(Some(1))?;
            match self {
                Kind::Exact(v) => {
                    struct _W<'a>(&'a ::buffa::alloc::vec::Vec<u8>);
                    impl serde::Serialize for _W<'_> {
                        fn serialize<S2: serde::Serializer>(
                            &self,
                            s: S2,
                        ) -> ::core::result::Result<S2::Ok, S2::Error> {
                            ::buffa::json_helpers::bytes::serialize(self.0, s)
                        }
                    }
                    map.serialize_entry("exact", &_W(v))?;
                }
                Kind::Prefix(v) => {
                    struct _W<'a>(&'a ::buffa::alloc::vec::Vec<u8>);
                    impl serde::Serialize for _W<'_> {
                        fn serialize<S2: serde::Serializer>(
                            &self,
                            s: S2,
                        ) -> ::core::result::Result<S2::Ok, S2::Error> {
                            ::buffa::json_helpers::bytes::serialize(self.0, s)
                        }
                    }
                    map.serialize_entry("prefix", &_W(v))?;
                }
                Kind::Regex(v) => {
                    map.serialize_entry("regex", v)?;
                }
            }
            map.end()
        }
    }
    #[derive(Clone, Debug)]
    pub enum KindView<'a> {
        Exact(&'a [u8]),
        Prefix(&'a [u8]),
        Regex(&'a str),
    }
}
