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

/// Live (and optionally replayed) subscription request.
#[derive(Clone, PartialEq, Default)]
#[derive(::serde::Serialize, ::serde::Deserialize)]
#[serde(default)]
pub struct SubscribeRequest {
    /// OR semantics across `match_keys`: a row is delivered if any match_key
    /// matches. Bounded to keep server-side regex compilation cost predictable.
    ///
    /// Field 1: `match_keys`
    #[serde(
        rename = "matchKeys",
        alias = "match_keys",
        skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_vec",
        deserialize_with = "::buffa::json_helpers::null_as_default"
    )]
    pub match_keys: ::buffa::alloc::vec::Vec<super::super::common::v1::MatchKey>,
    /// Optional value-side filter, AND'd with `match_keys`. OR semantics within
    /// the list: once a row's key passes a `MatchKey`, it is delivered only if
    /// its raw value bytes satisfy any one of `value_filters` (or the list is
    /// empty).
    ///
    /// Field 2: `value_filters`
    #[serde(
        rename = "valueFilters",
        alias = "value_filters",
        skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_vec",
        deserialize_with = "::buffa::json_helpers::null_as_default"
    )]
    pub value_filters: ::buffa::alloc::vec::Vec<super::super::common::v1::BytesFilter>,
    /// Optional replay cursor.
    ///
    /// Unset / 0 -\> subscription starts from the next live batch; no replay.
    ///
    /// Set to N -\> the server first replays every retained batch with
    /// `sequence_number >= N` in ascending order, then transitions seamlessly
    /// into the live stream. If `N` references a sequence number that has been
    /// evicted from the batch log, the server returns OUT_OF_RANGE with an
    /// `ErrorInfo { reason: "BATCH_EVICTED", metadata: { "oldest_retained": ... } }`
    /// detail so callers can decide how to proceed.
    ///
    /// Field 3: `since_sequence_number`
    #[serde(
        rename = "sinceSequenceNumber",
        alias = "since_sequence_number",
        with = "::buffa::json_helpers::opt_uint64",
        skip_serializing_if = "Option::is_none"
    )]
    pub since_sequence_number: Option<u64>,
    #[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 SubscribeRequest {
    fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
        f.debug_struct("SubscribeRequest")
            .field("match_keys", &self.match_keys)
            .field("value_filters", &self.value_filters)
            .field("since_sequence_number", &self.since_sequence_number)
            .finish()
    }
}
impl SubscribeRequest {
    /// 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.stream.v1.SubscribeRequest";
}
unsafe impl ::buffa::DefaultInstance for SubscribeRequest {
    fn default_instance() -> &'static Self {
        static VALUE: ::buffa::__private::OnceBox<SubscribeRequest> = ::buffa::__private::OnceBox::new();
        VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default()))
    }
}
impl ::buffa::Message for SubscribeRequest {
    /// 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 Some(v) = self.since_sequence_number {
            size += 1u32 + ::buffa::types::uint64_encoded_len(v) as u32;
        }
        for v in &self.match_keys {
            let inner_size = v.compute_size();
            size
                += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
                    + inner_size;
        }
        for v in &self.value_filters {
            let inner_size = v.compute_size();
            size
                += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
                    + inner_size;
        }
        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 Some(v) = self.since_sequence_number {
            ::buffa::encoding::Tag::new(3u32, ::buffa::encoding::WireType::Varint)
                .encode(buf);
            ::buffa::types::encode_uint64(v, buf);
        }
        for v in &self.match_keys {
            ::buffa::encoding::Tag::new(
                    1u32,
                    ::buffa::encoding::WireType::LengthDelimited,
                )
                .encode(buf);
            ::buffa::encoding::encode_varint(v.cached_size() as u64, buf);
            v.write_to(buf);
        }
        for v in &self.value_filters {
            ::buffa::encoding::Tag::new(
                    2u32,
                    ::buffa::encoding::WireType::LengthDelimited,
                )
                .encode(buf);
            ::buffa::encoding::encode_varint(v.cached_size() as u64, buf);
            v.write_to(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() {
            3u32 => {
                if tag.wire_type() != ::buffa::encoding::WireType::Varint {
                    return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
                        field_number: 3u32,
                        expected: 0u8,
                        actual: tag.wire_type() as u8,
                    });
                }
                self.since_sequence_number = ::core::option::Option::Some(
                    ::buffa::types::decode_uint64(buf)?,
                );
            }
            1u32 => {
                if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
                    return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
                        field_number: 1u32,
                        expected: 2u8,
                        actual: tag.wire_type() as u8,
                    });
                }
                let mut elem = ::core::default::Default::default();
                ::buffa::Message::merge_length_delimited(&mut elem, buf, depth)?;
                self.match_keys.push(elem);
            }
            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,
                    });
                }
                let mut elem = ::core::default::Default::default();
                ::buffa::Message::merge_length_delimited(&mut elem, buf, depth)?;
                self.value_filters.push(elem);
            }
            _ => {
                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.since_sequence_number = ::core::option::Option::None;
        self.match_keys.clear();
        self.value_filters.clear();
        self.__buffa_unknown_fields.clear();
        self.__buffa_cached_size.set(0);
    }
}
impl ::buffa::ExtensionSet for SubscribeRequest {
    const PROTO_FQN: &'static str = "store.stream.v1.SubscribeRequest";
    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 SubscribeRequest {
    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 __SUBSCRIBE_REQUEST_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry {
    type_url: "type.googleapis.com/store.stream.v1.SubscribeRequest",
    to_json: ::buffa::type_registry::any_to_json::<SubscribeRequest>,
    from_json: ::buffa::type_registry::any_from_json::<SubscribeRequest>,
    is_wkt: false,
};
/// Live (and optionally replayed) subscription request.
#[derive(Clone, Debug, Default)]
pub struct SubscribeRequestView<'a> {
    /// OR semantics across `match_keys`: a row is delivered if any match_key
    /// matches. Bounded to keep server-side regex compilation cost predictable.
    ///
    /// Field 1: `match_keys`
    pub match_keys: ::buffa::RepeatedView<
        'a,
        super::super::common::v1::MatchKeyView<'a>,
    >,
    /// Optional value-side filter, AND'd with `match_keys`. OR semantics within
    /// the list: once a row's key passes a `MatchKey`, it is delivered only if
    /// its raw value bytes satisfy any one of `value_filters` (or the list is
    /// empty).
    ///
    /// Field 2: `value_filters`
    pub value_filters: ::buffa::RepeatedView<
        'a,
        super::super::common::v1::BytesFilterView<'a>,
    >,
    /// Optional replay cursor.
    ///
    /// Unset / 0 -\> subscription starts from the next live batch; no replay.
    ///
    /// Set to N -\> the server first replays every retained batch with
    /// `sequence_number >= N` in ascending order, then transitions seamlessly
    /// into the live stream. If `N` references a sequence number that has been
    /// evicted from the batch log, the server returns OUT_OF_RANGE with an
    /// `ErrorInfo { reason: "BATCH_EVICTED", metadata: { "oldest_retained": ... } }`
    /// detail so callers can decide how to proceed.
    ///
    /// Field 3: `since_sequence_number`
    pub since_sequence_number: ::core::option::Option<u64>,
    pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
}
impl<'a> SubscribeRequestView<'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() {
                3u32 => {
                    if tag.wire_type() != ::buffa::encoding::WireType::Varint {
                        return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
                            field_number: 3u32,
                            expected: 0u8,
                            actual: tag.wire_type() as u8,
                        });
                    }
                    view.since_sequence_number = Some(
                        ::buffa::types::decode_uint64(&mut cur)?,
                    );
                }
                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.match_keys
                        .push(
                            super::super::common::v1::MatchKeyView::_decode_depth(
                                sub,
                                depth - 1,
                            )?,
                        );
                }
                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,
                        });
                    }
                    if depth == 0 {
                        return Err(::buffa::DecodeError::RecursionLimitExceeded);
                    }
                    let sub = ::buffa::types::borrow_bytes(&mut cur)?;
                    view.value_filters
                        .push(
                            super::super::common::v1::BytesFilterView::_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 SubscribeRequestView<'a> {
    type Owned = SubscribeRequest;
    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) -> SubscribeRequest {
        #[allow(unused_imports)]
        use ::buffa::alloc::string::ToString as _;
        SubscribeRequest {
            match_keys: self.match_keys.iter().map(|v| v.to_owned_message()).collect(),
            value_filters: self
                .value_filters
                .iter()
                .map(|v| v.to_owned_message())
                .collect(),
            since_sequence_number: self.since_sequence_number,
            __buffa_unknown_fields: self
                .__buffa_unknown_fields
                .to_owned()
                .unwrap_or_default()
                .into(),
            ..::core::default::Default::default()
        }
    }
}
unsafe impl ::buffa::DefaultViewInstance for SubscribeRequestView<'static> {
    fn default_view_instance() -> &'static Self {
        static VALUE: ::buffa::__private::OnceBox<SubscribeRequestView<'static>> = ::buffa::__private::OnceBox::new();
        VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default()))
    }
}
unsafe impl<'a> ::buffa::HasDefaultViewInstance for SubscribeRequestView<'a> {
    type Static = SubscribeRequestView<'static>;
}
/// Point-lookup for one historical batch. Always returns the complete batch.
#[derive(Clone, PartialEq, Default)]
#[derive(::serde::Serialize, ::serde::Deserialize)]
#[serde(default)]
pub struct GetRequest {
    /// Field 1: `sequence_number`
    #[serde(
        rename = "sequenceNumber",
        alias = "sequence_number",
        with = "::buffa::json_helpers::uint64",
        skip_serializing_if = "::buffa::json_helpers::skip_if::is_zero_u64"
    )]
    pub sequence_number: u64,
    #[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 GetRequest {
    fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
        f.debug_struct("GetRequest")
            .field("sequence_number", &self.sequence_number)
            .finish()
    }
}
impl GetRequest {
    /// 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.stream.v1.GetRequest";
}
unsafe impl ::buffa::DefaultInstance for GetRequest {
    fn default_instance() -> &'static Self {
        static VALUE: ::buffa::__private::OnceBox<GetRequest> = ::buffa::__private::OnceBox::new();
        VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default()))
    }
}
impl ::buffa::Message for GetRequest {
    /// 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.sequence_number != 0u64 {
            size
                += 1u32
                    + ::buffa::types::uint64_encoded_len(self.sequence_number) 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.sequence_number != 0u64 {
            ::buffa::encoding::Tag::new(1u32, ::buffa::encoding::WireType::Varint)
                .encode(buf);
            ::buffa::types::encode_uint64(self.sequence_number, 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.sequence_number = ::buffa::types::decode_uint64(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.sequence_number = 0u64;
        self.__buffa_unknown_fields.clear();
        self.__buffa_cached_size.set(0);
    }
}
impl ::buffa::ExtensionSet for GetRequest {
    const PROTO_FQN: &'static str = "store.stream.v1.GetRequest";
    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 GetRequest {
    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 __GET_REQUEST_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry {
    type_url: "type.googleapis.com/store.stream.v1.GetRequest",
    to_json: ::buffa::type_registry::any_to_json::<GetRequest>,
    from_json: ::buffa::type_registry::any_from_json::<GetRequest>,
    is_wkt: false,
};
/// Point-lookup for one historical batch. Always returns the complete batch.
#[derive(Clone, Debug, Default)]
pub struct GetRequestView<'a> {
    /// Field 1: `sequence_number`
    pub sequence_number: u64,
    pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
}
impl<'a> GetRequestView<'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.sequence_number = ::buffa::types::decode_uint64(&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 GetRequestView<'a> {
    type Owned = GetRequest;
    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) -> GetRequest {
        #[allow(unused_imports)]
        use ::buffa::alloc::string::ToString as _;
        GetRequest {
            sequence_number: self.sequence_number,
            __buffa_unknown_fields: self
                .__buffa_unknown_fields
                .to_owned()
                .unwrap_or_default()
                .into(),
            ..::core::default::Default::default()
        }
    }
}
unsafe impl ::buffa::DefaultViewInstance for GetRequestView<'static> {
    fn default_view_instance() -> &'static Self {
        static VALUE: ::buffa::__private::OnceBox<GetRequestView<'static>> = ::buffa::__private::OnceBox::new();
        VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default()))
    }
}
unsafe impl<'a> ::buffa::HasDefaultViewInstance for GetRequestView<'a> {
    type Static = GetRequestView<'static>;
}
/// One item delivered on a `Subscribe` stream: all rows from a single atomic
/// `Put` batch that matched the subscriber's filter. Live and replayed frames
/// are indistinguishable by content; only the observed `sequence_number`
/// (strictly monotonically increasing either way) differs.
#[derive(Clone, PartialEq, Default)]
#[derive(::serde::Serialize, ::serde::Deserialize)]
#[serde(default)]
pub struct SubscribeResponse {
    /// Field 1: `sequence_number`
    #[serde(
        rename = "sequenceNumber",
        alias = "sequence_number",
        with = "::buffa::json_helpers::uint64",
        skip_serializing_if = "::buffa::json_helpers::skip_if::is_zero_u64"
    )]
    pub sequence_number: u64,
    /// Field 2: `entries`
    #[serde(
        rename = "entries",
        skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_vec",
        deserialize_with = "::buffa::json_helpers::null_as_default"
    )]
    pub entries: ::buffa::alloc::vec::Vec<super::super::common::v1::KvEntry>,
    #[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 SubscribeResponse {
    fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
        f.debug_struct("SubscribeResponse")
            .field("sequence_number", &self.sequence_number)
            .field("entries", &self.entries)
            .finish()
    }
}
impl SubscribeResponse {
    /// 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.stream.v1.SubscribeResponse";
}
unsafe impl ::buffa::DefaultInstance for SubscribeResponse {
    fn default_instance() -> &'static Self {
        static VALUE: ::buffa::__private::OnceBox<SubscribeResponse> = ::buffa::__private::OnceBox::new();
        VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default()))
    }
}
impl ::buffa::Message for SubscribeResponse {
    /// 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.sequence_number != 0u64 {
            size
                += 1u32
                    + ::buffa::types::uint64_encoded_len(self.sequence_number) as u32;
        }
        for v in &self.entries {
            let inner_size = v.compute_size();
            size
                += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
                    + inner_size;
        }
        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.sequence_number != 0u64 {
            ::buffa::encoding::Tag::new(1u32, ::buffa::encoding::WireType::Varint)
                .encode(buf);
            ::buffa::types::encode_uint64(self.sequence_number, buf);
        }
        for v in &self.entries {
            ::buffa::encoding::Tag::new(
                    2u32,
                    ::buffa::encoding::WireType::LengthDelimited,
                )
                .encode(buf);
            ::buffa::encoding::encode_varint(v.cached_size() as u64, buf);
            v.write_to(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.sequence_number = ::buffa::types::decode_uint64(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,
                    });
                }
                let mut elem = ::core::default::Default::default();
                ::buffa::Message::merge_length_delimited(&mut elem, buf, depth)?;
                self.entries.push(elem);
            }
            _ => {
                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.sequence_number = 0u64;
        self.entries.clear();
        self.__buffa_unknown_fields.clear();
        self.__buffa_cached_size.set(0);
    }
}
impl ::buffa::ExtensionSet for SubscribeResponse {
    const PROTO_FQN: &'static str = "store.stream.v1.SubscribeResponse";
    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 SubscribeResponse {
    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 __SUBSCRIBE_RESPONSE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry {
    type_url: "type.googleapis.com/store.stream.v1.SubscribeResponse",
    to_json: ::buffa::type_registry::any_to_json::<SubscribeResponse>,
    from_json: ::buffa::type_registry::any_from_json::<SubscribeResponse>,
    is_wkt: false,
};
/// One item delivered on a `Subscribe` stream: all rows from a single atomic
/// `Put` batch that matched the subscriber's filter. Live and replayed frames
/// are indistinguishable by content; only the observed `sequence_number`
/// (strictly monotonically increasing either way) differs.
#[derive(Clone, Debug, Default)]
pub struct SubscribeResponseView<'a> {
    /// Field 1: `sequence_number`
    pub sequence_number: u64,
    /// Field 2: `entries`
    pub entries: ::buffa::RepeatedView<'a, super::super::common::v1::KvEntryView<'a>>,
    pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
}
impl<'a> SubscribeResponseView<'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.sequence_number = ::buffa::types::decode_uint64(&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,
                        });
                    }
                    if depth == 0 {
                        return Err(::buffa::DecodeError::RecursionLimitExceeded);
                    }
                    let sub = ::buffa::types::borrow_bytes(&mut cur)?;
                    view.entries
                        .push(
                            super::super::common::v1::KvEntryView::_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 SubscribeResponseView<'a> {
    type Owned = SubscribeResponse;
    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) -> SubscribeResponse {
        #[allow(unused_imports)]
        use ::buffa::alloc::string::ToString as _;
        SubscribeResponse {
            sequence_number: self.sequence_number,
            entries: self.entries.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()
        }
    }
}
unsafe impl ::buffa::DefaultViewInstance for SubscribeResponseView<'static> {
    fn default_view_instance() -> &'static Self {
        static VALUE: ::buffa::__private::OnceBox<SubscribeResponseView<'static>> = ::buffa::__private::OnceBox::new();
        VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default()))
    }
}
unsafe impl<'a> ::buffa::HasDefaultViewInstance for SubscribeResponseView<'a> {
    type Static = SubscribeResponseView<'static>;
}
/// Response for `Get`: the full contents of the batch at the requested
/// sequence number, with no server-side filter applied.
#[derive(Clone, PartialEq, Default)]
#[derive(::serde::Serialize, ::serde::Deserialize)]
#[serde(default)]
pub struct GetResponse {
    /// Field 1: `sequence_number`
    #[serde(
        rename = "sequenceNumber",
        alias = "sequence_number",
        with = "::buffa::json_helpers::uint64",
        skip_serializing_if = "::buffa::json_helpers::skip_if::is_zero_u64"
    )]
    pub sequence_number: u64,
    /// Field 2: `entries`
    #[serde(
        rename = "entries",
        skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_vec",
        deserialize_with = "::buffa::json_helpers::null_as_default"
    )]
    pub entries: ::buffa::alloc::vec::Vec<super::super::common::v1::KvEntry>,
    #[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 GetResponse {
    fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
        f.debug_struct("GetResponse")
            .field("sequence_number", &self.sequence_number)
            .field("entries", &self.entries)
            .finish()
    }
}
impl GetResponse {
    /// 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.stream.v1.GetResponse";
}
unsafe impl ::buffa::DefaultInstance for GetResponse {
    fn default_instance() -> &'static Self {
        static VALUE: ::buffa::__private::OnceBox<GetResponse> = ::buffa::__private::OnceBox::new();
        VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default()))
    }
}
impl ::buffa::Message for GetResponse {
    /// 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.sequence_number != 0u64 {
            size
                += 1u32
                    + ::buffa::types::uint64_encoded_len(self.sequence_number) as u32;
        }
        for v in &self.entries {
            let inner_size = v.compute_size();
            size
                += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
                    + inner_size;
        }
        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.sequence_number != 0u64 {
            ::buffa::encoding::Tag::new(1u32, ::buffa::encoding::WireType::Varint)
                .encode(buf);
            ::buffa::types::encode_uint64(self.sequence_number, buf);
        }
        for v in &self.entries {
            ::buffa::encoding::Tag::new(
                    2u32,
                    ::buffa::encoding::WireType::LengthDelimited,
                )
                .encode(buf);
            ::buffa::encoding::encode_varint(v.cached_size() as u64, buf);
            v.write_to(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.sequence_number = ::buffa::types::decode_uint64(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,
                    });
                }
                let mut elem = ::core::default::Default::default();
                ::buffa::Message::merge_length_delimited(&mut elem, buf, depth)?;
                self.entries.push(elem);
            }
            _ => {
                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.sequence_number = 0u64;
        self.entries.clear();
        self.__buffa_unknown_fields.clear();
        self.__buffa_cached_size.set(0);
    }
}
impl ::buffa::ExtensionSet for GetResponse {
    const PROTO_FQN: &'static str = "store.stream.v1.GetResponse";
    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 GetResponse {
    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 __GET_RESPONSE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry {
    type_url: "type.googleapis.com/store.stream.v1.GetResponse",
    to_json: ::buffa::type_registry::any_to_json::<GetResponse>,
    from_json: ::buffa::type_registry::any_from_json::<GetResponse>,
    is_wkt: false,
};
/// Response for `Get`: the full contents of the batch at the requested
/// sequence number, with no server-side filter applied.
#[derive(Clone, Debug, Default)]
pub struct GetResponseView<'a> {
    /// Field 1: `sequence_number`
    pub sequence_number: u64,
    /// Field 2: `entries`
    pub entries: ::buffa::RepeatedView<'a, super::super::common::v1::KvEntryView<'a>>,
    pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
}
impl<'a> GetResponseView<'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.sequence_number = ::buffa::types::decode_uint64(&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,
                        });
                    }
                    if depth == 0 {
                        return Err(::buffa::DecodeError::RecursionLimitExceeded);
                    }
                    let sub = ::buffa::types::borrow_bytes(&mut cur)?;
                    view.entries
                        .push(
                            super::super::common::v1::KvEntryView::_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 GetResponseView<'a> {
    type Owned = GetResponse;
    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) -> GetResponse {
        #[allow(unused_imports)]
        use ::buffa::alloc::string::ToString as _;
        GetResponse {
            sequence_number: self.sequence_number,
            entries: self.entries.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()
        }
    }
}
unsafe impl ::buffa::DefaultViewInstance for GetResponseView<'static> {
    fn default_view_instance() -> &'static Self {
        static VALUE: ::buffa::__private::OnceBox<GetResponseView<'static>> = ::buffa::__private::OnceBox::new();
        VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default()))
    }
}
unsafe impl<'a> ::buffa::HasDefaultViewInstance for GetResponseView<'a> {
    type Static = GetResponseView<'static>;
}

/// Full service name for this service.
pub const SERVICE_SERVICE_NAME: &str = "store.stream.v1.Service";
/// Push-based subscription + point-lookup over the store's batch log.
/// `Subscribe` delivers a `SubscribeResponse` per atomic `Put` batch whose
/// entries match any of the subscriber's `match_keys`. Optional
/// `since_sequence_number` replays retained batches before transitioning live.
/// `Get` returns the complete batch at a given sequence number (no filter
/// applied server-side). `SubscribeResponse` and `GetResponse` carry the
/// same shape so callers can share decoders.
///
/// # Implementing handlers
///
/// Handlers receive requests as `OwnedView<FooView<'static>>`, which gives
/// zero-copy borrowed access to fields (e.g. `request.name` is a `&str`
/// into the decoded buffer). The view can be held across `.await` points.
///
/// Implement methods with plain `async fn`; the returned future satisfies
/// the `Send` bound automatically. See the
/// [buffa user guide](https://github.com/anthropics/buffa/blob/main/docs/guide.md#ownedview-in-async-trait-implementations)
/// for zero-copy access patterns and when `to_owned_message()` is needed.
#[allow(clippy::type_complexity)]
pub trait Service: Send + Sync + 'static {
    /// Handle the Subscribe RPC.
    fn subscribe(
        &self,
        ctx: ::connectrpc::Context,
        request: ::buffa::view::OwnedView<SubscribeRequestView<'static>>,
    ) -> impl ::std::future::Future<
        Output = Result<
            (
                ::std::pin::Pin<
                    Box<
                        dyn ::futures::Stream<
                            Item = Result<SubscribeResponse, ::connectrpc::ConnectError>,
                        > + Send,
                    >,
                >,
                ::connectrpc::Context,
            ),
            ::connectrpc::ConnectError,
        >,
    > + Send;
    /// Handle the Get RPC.
    fn get(
        &self,
        ctx: ::connectrpc::Context,
        request: ::buffa::view::OwnedView<GetRequestView<'static>>,
    ) -> impl ::std::future::Future<
        Output = Result<(GetResponse, ::connectrpc::Context), ::connectrpc::ConnectError>,
    > + Send;
}
/// Extension trait for registering a service implementation with a Router.
///
/// This trait is automatically implemented for all types that implement the service trait.
///
/// # Example
///
/// ```rust,ignore
/// use std::sync::Arc;
///
/// let service = Arc::new(MyServiceImpl);
/// let router = service.register(Router::new());
/// ```
pub trait ServiceExt: Service {
    /// Register this service implementation with a Router.
    ///
    /// Takes ownership of the `Arc<Self>` and returns a new Router with
    /// this service's methods registered.
    fn register(
        self: ::std::sync::Arc<Self>,
        router: ::connectrpc::Router,
    ) -> ::connectrpc::Router;
}
impl<S: Service> ServiceExt for S {
    fn register(
        self: ::std::sync::Arc<Self>,
        router: ::connectrpc::Router,
    ) -> ::connectrpc::Router {
        router
            .route_view_server_stream(
                SERVICE_SERVICE_NAME,
                "Subscribe",
                ::connectrpc::view_streaming_handler_fn({
                    let svc = ::std::sync::Arc::clone(&self);
                    move |ctx, req| {
                        let svc = ::std::sync::Arc::clone(&svc);
                        async move { svc.subscribe(ctx, req).await }
                    }
                }),
            )
            .route_view(
                SERVICE_SERVICE_NAME,
                "Get",
                {
                    let svc = ::std::sync::Arc::clone(&self);
                    ::connectrpc::view_handler_fn(move |ctx, req| {
                        let svc = ::std::sync::Arc::clone(&svc);
                        async move { svc.get(ctx, req).await }
                    })
                },
            )
    }
}
/// Monomorphic dispatcher for `Service`.
///
/// Unlike `.register(Router)` which type-erases each method into an `Arc<dyn ErasedHandler>` stored in a `HashMap`, this struct dispatches via a compile-time `match` on method name: no vtable, no hash lookup.
///
/// # Example
///
/// ```rust,ignore
/// use connectrpc::ConnectRpcService;
///
/// let server = ServiceServer::new(MyImpl);
/// let service = ConnectRpcService::new(server);
/// // hand `service` to axum/hyper as a fallback_service
/// ```
pub struct ServiceServer<T> {
    inner: ::std::sync::Arc<T>,
}
impl<T: Service> ServiceServer<T> {
    /// Wrap a service implementation in a monomorphic dispatcher.
    pub fn new(service: T) -> Self {
        Self {
            inner: ::std::sync::Arc::new(service),
        }
    }
    /// Wrap an already-`Arc`'d service implementation.
    pub fn from_arc(inner: ::std::sync::Arc<T>) -> Self {
        Self { inner }
    }
}
impl<T> Clone for ServiceServer<T> {
    fn clone(&self) -> Self {
        Self {
            inner: ::std::sync::Arc::clone(&self.inner),
        }
    }
}
impl<T: Service> ::connectrpc::Dispatcher for ServiceServer<T> {
    #[inline]
    fn lookup(
        &self,
        path: &str,
    ) -> Option<::connectrpc::dispatcher::codegen::MethodDescriptor> {
        let method = path.strip_prefix("store.stream.v1.Service/")?;
        match method {
            "Subscribe" => {
                Some(
                    ::connectrpc::dispatcher::codegen::MethodDescriptor::server_streaming(),
                )
            }
            "Get" => {
                Some(::connectrpc::dispatcher::codegen::MethodDescriptor::unary(false))
            }
            _ => None,
        }
    }
    fn call_unary(
        &self,
        path: &str,
        ctx: ::connectrpc::Context,
        request: ::buffa::bytes::Bytes,
        format: ::connectrpc::CodecFormat,
    ) -> ::connectrpc::dispatcher::codegen::UnaryResult {
        let Some(method) = path.strip_prefix("store.stream.v1.Service/") else {
            return ::connectrpc::dispatcher::codegen::unimplemented_unary(path);
        };
        let _ = (&ctx, &request, &format);
        match method {
            "Get" => {
                let svc = ::std::sync::Arc::clone(&self.inner);
                Box::pin(async move {
                    let req = ::connectrpc::dispatcher::codegen::decode_request_view::<
                        GetRequestView,
                    >(request, format)?;
                    let (res, ctx) = svc.get(ctx, req).await?;
                    let bytes = ::connectrpc::dispatcher::codegen::encode_response(
                        &res,
                        format,
                    )?;
                    Ok((bytes, ctx))
                })
            }
            _ => ::connectrpc::dispatcher::codegen::unimplemented_unary(path),
        }
    }
    fn call_server_streaming(
        &self,
        path: &str,
        ctx: ::connectrpc::Context,
        request: ::buffa::bytes::Bytes,
        format: ::connectrpc::CodecFormat,
    ) -> ::connectrpc::dispatcher::codegen::StreamingResult {
        let Some(method) = path.strip_prefix("store.stream.v1.Service/") else {
            return ::connectrpc::dispatcher::codegen::unimplemented_streaming(path);
        };
        let _ = (&ctx, &request, &format);
        match method {
            "Subscribe" => {
                let svc = ::std::sync::Arc::clone(&self.inner);
                Box::pin(async move {
                    let req = ::connectrpc::dispatcher::codegen::decode_request_view::<
                        SubscribeRequestView,
                    >(request, format)?;
                    let (resp_stream, ctx) = svc.subscribe(ctx, req).await?;
                    Ok((
                        ::connectrpc::dispatcher::codegen::encode_response_stream(
                            resp_stream,
                            format,
                        ),
                        ctx,
                    ))
                })
            }
            _ => ::connectrpc::dispatcher::codegen::unimplemented_streaming(path),
        }
    }
    fn call_client_streaming(
        &self,
        path: &str,
        ctx: ::connectrpc::Context,
        requests: ::connectrpc::dispatcher::codegen::RequestStream,
        format: ::connectrpc::CodecFormat,
    ) -> ::connectrpc::dispatcher::codegen::UnaryResult {
        let Some(method) = path.strip_prefix("store.stream.v1.Service/") else {
            return ::connectrpc::dispatcher::codegen::unimplemented_unary(path);
        };
        let _ = (&ctx, &requests, &format);
        match method {
            _ => ::connectrpc::dispatcher::codegen::unimplemented_unary(path),
        }
    }
    fn call_bidi_streaming(
        &self,
        path: &str,
        ctx: ::connectrpc::Context,
        requests: ::connectrpc::dispatcher::codegen::RequestStream,
        format: ::connectrpc::CodecFormat,
    ) -> ::connectrpc::dispatcher::codegen::StreamingResult {
        let Some(method) = path.strip_prefix("store.stream.v1.Service/") else {
            return ::connectrpc::dispatcher::codegen::unimplemented_streaming(path);
        };
        let _ = (&ctx, &requests, &format);
        match method {
            _ => ::connectrpc::dispatcher::codegen::unimplemented_streaming(path),
        }
    }
}
/// Client for this service.
///
/// Generic over `T: ClientTransport`. For **gRPC** (HTTP/2), use
/// `Http2Connection` — it has honest `poll_ready` and composes with
/// `tower::balance` for multi-connection load balancing. For **Connect
/// over HTTP/1.1** (or unknown protocol), use `HttpClient`.
///
/// # Example (gRPC / HTTP/2)
///
/// ```rust,ignore
/// use connectrpc::client::{Http2Connection, ClientConfig};
/// use connectrpc::Protocol;
///
/// let uri: http::Uri = "http://localhost:8080".parse()?;
/// let conn = Http2Connection::connect_plaintext(uri.clone()).await?.shared(1024);
/// let config = ClientConfig::new(uri).protocol(Protocol::Grpc);
///
/// let client = ServiceClient::new(conn, config);
/// let response = client.subscribe(request).await?;
/// ```
///
/// # Example (Connect / HTTP/1.1 or ALPN)
///
/// ```rust,ignore
/// use connectrpc::client::{HttpClient, ClientConfig};
///
/// let http = HttpClient::plaintext();  // cleartext http:// only
/// let config = ClientConfig::new("http://localhost:8080".parse()?);
///
/// let client = ServiceClient::new(http, config);
/// let response = client.subscribe(request).await?;
/// ```
///
/// # Working with the response
///
/// Unary calls return [`UnaryResponse<OwnedView<FooView>>`](::connectrpc::client::UnaryResponse).
/// The `OwnedView` derefs to the view, so field access is zero-copy:
///
/// ```rust,ignore
/// let resp = client.subscribe(request).await?.into_view();
/// let name: &str = resp.name;  // borrow into the response buffer
/// ```
///
/// If you need the owned struct (e.g. to store or pass by value), use
/// [`into_owned()`](::connectrpc::client::UnaryResponse::into_owned):
///
/// ```rust,ignore
/// let owned = client.subscribe(request).await?.into_owned();
/// ```
#[derive(Clone)]
pub struct ServiceClient<T> {
    transport: T,
    config: ::connectrpc::client::ClientConfig,
}
impl<T> ServiceClient<T>
where
    T: ::connectrpc::client::ClientTransport,
    <T::ResponseBody as ::http_body::Body>::Error: ::std::fmt::Display,
{
    /// Create a new client with the given transport and configuration.
    pub fn new(transport: T, config: ::connectrpc::client::ClientConfig) -> Self {
        Self { transport, config }
    }
    /// Get the client configuration.
    pub fn config(&self) -> &::connectrpc::client::ClientConfig {
        &self.config
    }
    /// Get a mutable reference to the client configuration.
    pub fn config_mut(&mut self) -> &mut ::connectrpc::client::ClientConfig {
        &mut self.config
    }
    /// Call the Subscribe RPC. Sends a request to /store.stream.v1.Service/Subscribe.
    pub async fn subscribe(
        &self,
        request: SubscribeRequest,
    ) -> Result<
        ::connectrpc::client::ServerStream<
            T::ResponseBody,
            SubscribeResponseView<'static>,
        >,
        ::connectrpc::ConnectError,
    > {
        self.subscribe_with_options(
                request,
                ::connectrpc::client::CallOptions::default(),
            )
            .await
    }
    /// Call the Subscribe RPC with explicit per-call options. Options override [`connectrpc::client::ClientConfig`] defaults.
    pub async fn subscribe_with_options(
        &self,
        request: SubscribeRequest,
        options: ::connectrpc::client::CallOptions,
    ) -> Result<
        ::connectrpc::client::ServerStream<
            T::ResponseBody,
            SubscribeResponseView<'static>,
        >,
        ::connectrpc::ConnectError,
    > {
        ::connectrpc::client::call_server_stream(
                &self.transport,
                &self.config,
                SERVICE_SERVICE_NAME,
                "Subscribe",
                request,
                options,
            )
            .await
    }
    /// Call the Get RPC. Sends a request to /store.stream.v1.Service/Get.
    pub async fn get(
        &self,
        request: GetRequest,
    ) -> Result<
        ::connectrpc::client::UnaryResponse<
            ::buffa::view::OwnedView<GetResponseView<'static>>,
        >,
        ::connectrpc::ConnectError,
    > {
        self.get_with_options(request, ::connectrpc::client::CallOptions::default())
            .await
    }
    /// Call the Get RPC with explicit per-call options. Options override [`connectrpc::client::ClientConfig`] defaults.
    pub async fn get_with_options(
        &self,
        request: GetRequest,
        options: ::connectrpc::client::CallOptions,
    ) -> Result<
        ::connectrpc::client::UnaryResponse<
            ::buffa::view::OwnedView<GetResponseView<'static>>,
        >,
        ::connectrpc::ConnectError,
    > {
        ::connectrpc::client::call_unary(
                &self.transport,
                &self.config,
                SERVICE_SERVICE_NAME,
                "Get",
                request,
                options,
            )
            .await
    }
}
