Skip to main content

exoware_sdk/gen/
store.v1.compact.rs

1// @generated by protoc-gen-buffa. DO NOT EDIT.
2// source: store/v1/compact.proto
3
4/// Interpretation of the order-by capture group bytes when comparing keys
5/// within a group.
6#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
7#[repr(i32)]
8pub enum PolicyOrderEncoding {
9    /// Raw byte-wise ascending comparison (the default).
10    POLICY_ORDER_ENCODING_BYTES_ASC = 0i32,
11    /// Interpret the captured bytes as a big-endian u64 (must be exactly 8 bytes).
12    POLICY_ORDER_ENCODING_U64_BE = 1i32,
13    /// Interpret the captured bytes as a big-endian i64 (must be exactly 8 bytes).
14    POLICY_ORDER_ENCODING_I64_BE = 2i32,
15}
16impl ::core::default::Default for PolicyOrderEncoding {
17    fn default() -> Self {
18        Self::POLICY_ORDER_ENCODING_BYTES_ASC
19    }
20}
21impl ::serde::Serialize for PolicyOrderEncoding {
22    fn serialize<S: ::serde::Serializer>(
23        &self,
24        s: S,
25    ) -> ::core::result::Result<S::Ok, S::Error> {
26        s.serialize_str(::buffa::Enumeration::proto_name(self))
27    }
28}
29impl<'de> ::serde::Deserialize<'de> for PolicyOrderEncoding {
30    fn deserialize<D: ::serde::Deserializer<'de>>(
31        d: D,
32    ) -> ::core::result::Result<Self, D::Error> {
33        struct _V;
34        impl ::serde::de::Visitor<'_> for _V {
35            type Value = PolicyOrderEncoding;
36            fn expecting(
37                &self,
38                f: &mut ::core::fmt::Formatter<'_>,
39            ) -> ::core::fmt::Result {
40                f.write_str(
41                    concat!(
42                        "a string, integer, or null for ",
43                        stringify!(PolicyOrderEncoding)
44                    ),
45                )
46            }
47            fn visit_str<E: ::serde::de::Error>(
48                self,
49                v: &str,
50            ) -> ::core::result::Result<PolicyOrderEncoding, E> {
51                <PolicyOrderEncoding as ::buffa::Enumeration>::from_proto_name(v)
52                    .ok_or_else(|| { ::serde::de::Error::unknown_variant(v, &[]) })
53            }
54            fn visit_i64<E: ::serde::de::Error>(
55                self,
56                v: i64,
57            ) -> ::core::result::Result<PolicyOrderEncoding, E> {
58                let v32 = i32::try_from(v)
59                    .map_err(|_| {
60                        ::serde::de::Error::custom(
61                            ::buffa::alloc::format!("enum value {} out of i32 range", v),
62                        )
63                    })?;
64                <PolicyOrderEncoding as ::buffa::Enumeration>::from_i32(v32)
65                    .ok_or_else(|| {
66                        ::serde::de::Error::custom(
67                            ::buffa::alloc::format!("unknown enum value {}", v32),
68                        )
69                    })
70            }
71            fn visit_u64<E: ::serde::de::Error>(
72                self,
73                v: u64,
74            ) -> ::core::result::Result<PolicyOrderEncoding, E> {
75                let v32 = i32::try_from(v)
76                    .map_err(|_| {
77                        ::serde::de::Error::custom(
78                            ::buffa::alloc::format!("enum value {} out of i32 range", v),
79                        )
80                    })?;
81                <PolicyOrderEncoding as ::buffa::Enumeration>::from_i32(v32)
82                    .ok_or_else(|| {
83                        ::serde::de::Error::custom(
84                            ::buffa::alloc::format!("unknown enum value {}", v32),
85                        )
86                    })
87            }
88            fn visit_unit<E: ::serde::de::Error>(
89                self,
90            ) -> ::core::result::Result<PolicyOrderEncoding, E> {
91                ::core::result::Result::Ok(::core::default::Default::default())
92            }
93        }
94        d.deserialize_any(_V)
95    }
96}
97impl ::buffa::json_helpers::ProtoElemJson for PolicyOrderEncoding {
98    fn serialize_proto_json<S: ::serde::Serializer>(
99        v: &Self,
100        s: S,
101    ) -> ::core::result::Result<S::Ok, S::Error> {
102        ::serde::Serialize::serialize(v, s)
103    }
104    fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>(
105        d: D,
106    ) -> ::core::result::Result<Self, D::Error> {
107        <Self as ::serde::Deserialize>::deserialize(d)
108    }
109}
110impl ::buffa::Enumeration for PolicyOrderEncoding {
111    fn from_i32(value: i32) -> ::core::option::Option<Self> {
112        match value {
113            0i32 => ::core::option::Option::Some(Self::POLICY_ORDER_ENCODING_BYTES_ASC),
114            1i32 => ::core::option::Option::Some(Self::POLICY_ORDER_ENCODING_U64_BE),
115            2i32 => ::core::option::Option::Some(Self::POLICY_ORDER_ENCODING_I64_BE),
116            _ => ::core::option::Option::None,
117        }
118    }
119    fn to_i32(&self) -> i32 {
120        *self as i32
121    }
122    fn proto_name(&self) -> &'static str {
123        match self {
124            Self::POLICY_ORDER_ENCODING_BYTES_ASC => "POLICY_ORDER_ENCODING_BYTES_ASC",
125            Self::POLICY_ORDER_ENCODING_U64_BE => "POLICY_ORDER_ENCODING_U64_BE",
126            Self::POLICY_ORDER_ENCODING_I64_BE => "POLICY_ORDER_ENCODING_I64_BE",
127        }
128    }
129    fn from_proto_name(name: &str) -> ::core::option::Option<Self> {
130        match name {
131            "POLICY_ORDER_ENCODING_BYTES_ASC" => {
132                ::core::option::Option::Some(Self::POLICY_ORDER_ENCODING_BYTES_ASC)
133            }
134            "POLICY_ORDER_ENCODING_U64_BE" => {
135                ::core::option::Option::Some(Self::POLICY_ORDER_ENCODING_U64_BE)
136            }
137            "POLICY_ORDER_ENCODING_I64_BE" => {
138                ::core::option::Option::Some(Self::POLICY_ORDER_ENCODING_I64_BE)
139            }
140            _ => ::core::option::Option::None,
141        }
142    }
143}
144/// Prune policy graph and admin RPC (served by the compaction worker).
145///
146/// Controls how matched keys are partitioned into independent groups before
147/// the retain policy is applied. Each group is pruned independently.
148#[derive(Clone, PartialEq, Default)]
149#[derive(::serde::Serialize, ::serde::Deserialize)]
150#[serde(default)]
151pub struct PolicyGroupBy {
152    /// Named capture groups from `store.common.v1.MatchKey.payload_regex` whose
153    /// matched bytes are concatenated (length-prefixed) to form each group's
154    /// identity. Must not contain duplicates. When empty, all matched keys
155    /// belong to a single group.
156    ///
157    /// Field 1: `capture_groups`
158    #[serde(
159        rename = "captureGroups",
160        alias = "capture_groups",
161        skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_vec",
162        deserialize_with = "::buffa::json_helpers::null_as_default"
163    )]
164    pub capture_groups: ::buffa::alloc::vec::Vec<::buffa::alloc::string::String>,
165    #[serde(skip)]
166    #[doc(hidden)]
167    pub __buffa_unknown_fields: ::buffa::UnknownFields,
168    #[doc(hidden)]
169    #[serde(skip)]
170    pub __buffa_cached_size: ::buffa::__private::CachedSize,
171}
172impl ::core::fmt::Debug for PolicyGroupBy {
173    fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
174        f.debug_struct("PolicyGroupBy")
175            .field("capture_groups", &self.capture_groups)
176            .finish()
177    }
178}
179impl PolicyGroupBy {
180    /// Protobuf type URL for this message, for use with `Any::pack` and
181    /// `Any::unpack_if`.
182    ///
183    /// Format: `type.googleapis.com/<fully.qualified.TypeName>`
184    pub const TYPE_URL: &'static str = "type.googleapis.com/store.compact.v1.PolicyGroupBy";
185}
186unsafe impl ::buffa::DefaultInstance for PolicyGroupBy {
187    fn default_instance() -> &'static Self {
188        static VALUE: ::buffa::__private::OnceBox<PolicyGroupBy> = ::buffa::__private::OnceBox::new();
189        VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default()))
190    }
191}
192impl ::buffa::Message for PolicyGroupBy {
193    /// Returns the total encoded size in bytes.
194    ///
195    /// The result is a `u32`; the protobuf specification requires all
196    /// messages to fit within 2 GiB (2,147,483,647 bytes), so a
197    /// compliant message will never overflow this type.
198    fn compute_size(&self) -> u32 {
199        #[allow(unused_imports)]
200        use ::buffa::Enumeration as _;
201        let mut size = 0u32;
202        for v in &self.capture_groups {
203            size += 1u32 + ::buffa::types::string_encoded_len(v) as u32;
204        }
205        size += self.__buffa_unknown_fields.encoded_len() as u32;
206        self.__buffa_cached_size.set(size);
207        size
208    }
209    fn write_to(&self, buf: &mut impl ::buffa::bytes::BufMut) {
210        #[allow(unused_imports)]
211        use ::buffa::Enumeration as _;
212        for v in &self.capture_groups {
213            ::buffa::encoding::Tag::new(
214                    1u32,
215                    ::buffa::encoding::WireType::LengthDelimited,
216                )
217                .encode(buf);
218            ::buffa::types::encode_string(v, buf);
219        }
220        self.__buffa_unknown_fields.write_to(buf);
221    }
222    fn merge_field(
223        &mut self,
224        tag: ::buffa::encoding::Tag,
225        buf: &mut impl ::buffa::bytes::Buf,
226        depth: u32,
227    ) -> ::core::result::Result<(), ::buffa::DecodeError> {
228        #[allow(unused_imports)]
229        use ::buffa::bytes::Buf as _;
230        #[allow(unused_imports)]
231        use ::buffa::Enumeration as _;
232        match tag.field_number() {
233            1u32 => {
234                if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
235                    return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
236                        field_number: 1u32,
237                        expected: 2u8,
238                        actual: tag.wire_type() as u8,
239                    });
240                }
241                self.capture_groups.push(::buffa::types::decode_string(buf)?);
242            }
243            _ => {
244                self.__buffa_unknown_fields
245                    .push(::buffa::encoding::decode_unknown_field(tag, buf, depth)?);
246            }
247        }
248        ::core::result::Result::Ok(())
249    }
250    fn cached_size(&self) -> u32 {
251        self.__buffa_cached_size.get()
252    }
253    fn clear(&mut self) {
254        self.capture_groups.clear();
255        self.__buffa_unknown_fields.clear();
256        self.__buffa_cached_size.set(0);
257    }
258}
259impl ::buffa::ExtensionSet for PolicyGroupBy {
260    const PROTO_FQN: &'static str = "store.compact.v1.PolicyGroupBy";
261    fn unknown_fields(&self) -> &::buffa::UnknownFields {
262        &self.__buffa_unknown_fields
263    }
264    fn unknown_fields_mut(&mut self) -> &mut ::buffa::UnknownFields {
265        &mut self.__buffa_unknown_fields
266    }
267}
268impl ::buffa::json_helpers::ProtoElemJson for PolicyGroupBy {
269    fn serialize_proto_json<S: ::serde::Serializer>(
270        v: &Self,
271        s: S,
272    ) -> ::core::result::Result<S::Ok, S::Error> {
273        ::serde::Serialize::serialize(v, s)
274    }
275    fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>(
276        d: D,
277    ) -> ::core::result::Result<Self, D::Error> {
278        <Self as ::serde::Deserialize>::deserialize(d)
279    }
280}
281#[doc(hidden)]
282pub const __POLICY_GROUP_BY_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry {
283    type_url: "type.googleapis.com/store.compact.v1.PolicyGroupBy",
284    to_json: ::buffa::type_registry::any_to_json::<PolicyGroupBy>,
285    from_json: ::buffa::type_registry::any_from_json::<PolicyGroupBy>,
286    is_wkt: false,
287};
288/// Prune policy graph and admin RPC (served by the compaction worker).
289///
290/// Controls how matched keys are partitioned into independent groups before
291/// the retain policy is applied. Each group is pruned independently.
292#[derive(Clone, Debug, Default)]
293pub struct PolicyGroupByView<'a> {
294    /// Named capture groups from `store.common.v1.MatchKey.payload_regex` whose
295    /// matched bytes are concatenated (length-prefixed) to form each group's
296    /// identity. Must not contain duplicates. When empty, all matched keys
297    /// belong to a single group.
298    ///
299    /// Field 1: `capture_groups`
300    pub capture_groups: ::buffa::RepeatedView<'a, &'a str>,
301    pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
302}
303impl<'a> PolicyGroupByView<'a> {
304    /// Decode from `buf`, enforcing a recursion depth limit for nested messages.
305    ///
306    /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`]
307    /// and by generated sub-message decode arms with `depth - 1`.
308    ///
309    /// **Not part of the public API.** Named with a leading underscore to
310    /// signal that it is for generated-code use only.
311    #[doc(hidden)]
312    pub fn _decode_depth(
313        buf: &'a [u8],
314        depth: u32,
315    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
316        let mut view = Self::default();
317        view._merge_into_view(buf, depth)?;
318        ::core::result::Result::Ok(view)
319    }
320    /// Merge fields from `buf` into this view (proto merge semantics).
321    ///
322    /// Repeated fields append; singular fields last-wins; singular
323    /// MESSAGE fields merge recursively. Used by sub-message decode
324    /// arms when the same field appears multiple times on the wire.
325    ///
326    /// **Not part of the public API.**
327    #[doc(hidden)]
328    pub fn _merge_into_view(
329        &mut self,
330        buf: &'a [u8],
331        depth: u32,
332    ) -> ::core::result::Result<(), ::buffa::DecodeError> {
333        let _ = depth;
334        #[allow(unused_variables)]
335        let view = self;
336        let mut cur: &'a [u8] = buf;
337        while !cur.is_empty() {
338            let before_tag = cur;
339            let tag = ::buffa::encoding::Tag::decode(&mut cur)?;
340            match tag.field_number() {
341                1u32 => {
342                    if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
343                        return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
344                            field_number: 1u32,
345                            expected: 2u8,
346                            actual: tag.wire_type() as u8,
347                        });
348                    }
349                    view.capture_groups.push(::buffa::types::borrow_str(&mut cur)?);
350                }
351                _ => {
352                    ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?;
353                    let span_len = before_tag.len() - cur.len();
354                    view.__buffa_unknown_fields.push_raw(&before_tag[..span_len]);
355                }
356            }
357        }
358        ::core::result::Result::Ok(())
359    }
360}
361impl<'a> ::buffa::MessageView<'a> for PolicyGroupByView<'a> {
362    type Owned = PolicyGroupBy;
363    fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
364        Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT)
365    }
366    fn decode_view_with_limit(
367        buf: &'a [u8],
368        depth: u32,
369    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
370        Self::_decode_depth(buf, depth)
371    }
372    /// Convert this view to the owned message type.
373    #[allow(clippy::redundant_closure, clippy::useless_conversion)]
374    fn to_owned_message(&self) -> PolicyGroupBy {
375        #[allow(unused_imports)]
376        use ::buffa::alloc::string::ToString as _;
377        PolicyGroupBy {
378            capture_groups: self.capture_groups.iter().map(|s| s.to_string()).collect(),
379            __buffa_unknown_fields: self
380                .__buffa_unknown_fields
381                .to_owned()
382                .unwrap_or_default()
383                .into(),
384            ..::core::default::Default::default()
385        }
386    }
387}
388unsafe impl ::buffa::DefaultViewInstance for PolicyGroupByView<'static> {
389    fn default_view_instance() -> &'static Self {
390        static VALUE: ::buffa::__private::OnceBox<PolicyGroupByView<'static>> = ::buffa::__private::OnceBox::new();
391        VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default()))
392    }
393}
394unsafe impl<'a> ::buffa::HasDefaultViewInstance for PolicyGroupByView<'a> {
395    type Static = PolicyGroupByView<'static>;
396}
397/// Defines the sort order within each group. The named capture group is
398/// extracted from the payload regex and decoded according to `encoding`.
399/// Required for `RetainKeepLatest` and threshold-based retain policies.
400#[derive(Clone, PartialEq, Default)]
401#[derive(::serde::Serialize, ::serde::Deserialize)]
402#[serde(default)]
403pub struct PolicyOrderBy {
404    /// Name of the capture group in `store.common.v1.MatchKey.payload_regex`
405    /// that provides the ordering value.
406    ///
407    /// Field 1: `capture_group`
408    #[serde(
409        rename = "captureGroup",
410        alias = "capture_group",
411        with = "::buffa::json_helpers::proto_string",
412        skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_str"
413    )]
414    pub capture_group: ::buffa::alloc::string::String,
415    /// How to decode and compare the captured bytes.
416    ///
417    /// Field 2: `encoding`
418    #[serde(
419        rename = "encoding",
420        with = "::buffa::json_helpers::proto_enum",
421        skip_serializing_if = "::buffa::json_helpers::skip_if::is_default_enum_value"
422    )]
423    pub encoding: ::buffa::EnumValue<PolicyOrderEncoding>,
424    #[serde(skip)]
425    #[doc(hidden)]
426    pub __buffa_unknown_fields: ::buffa::UnknownFields,
427    #[doc(hidden)]
428    #[serde(skip)]
429    pub __buffa_cached_size: ::buffa::__private::CachedSize,
430}
431impl ::core::fmt::Debug for PolicyOrderBy {
432    fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
433        f.debug_struct("PolicyOrderBy")
434            .field("capture_group", &self.capture_group)
435            .field("encoding", &self.encoding)
436            .finish()
437    }
438}
439impl PolicyOrderBy {
440    /// Protobuf type URL for this message, for use with `Any::pack` and
441    /// `Any::unpack_if`.
442    ///
443    /// Format: `type.googleapis.com/<fully.qualified.TypeName>`
444    pub const TYPE_URL: &'static str = "type.googleapis.com/store.compact.v1.PolicyOrderBy";
445}
446unsafe impl ::buffa::DefaultInstance for PolicyOrderBy {
447    fn default_instance() -> &'static Self {
448        static VALUE: ::buffa::__private::OnceBox<PolicyOrderBy> = ::buffa::__private::OnceBox::new();
449        VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default()))
450    }
451}
452impl ::buffa::Message for PolicyOrderBy {
453    /// Returns the total encoded size in bytes.
454    ///
455    /// The result is a `u32`; the protobuf specification requires all
456    /// messages to fit within 2 GiB (2,147,483,647 bytes), so a
457    /// compliant message will never overflow this type.
458    fn compute_size(&self) -> u32 {
459        #[allow(unused_imports)]
460        use ::buffa::Enumeration as _;
461        let mut size = 0u32;
462        if !self.capture_group.is_empty() {
463            size
464                += 1u32 + ::buffa::types::string_encoded_len(&self.capture_group) as u32;
465        }
466        {
467            let val = self.encoding.to_i32();
468            if val != 0 {
469                size += 1u32 + ::buffa::types::int32_encoded_len(val) as u32;
470            }
471        }
472        size += self.__buffa_unknown_fields.encoded_len() as u32;
473        self.__buffa_cached_size.set(size);
474        size
475    }
476    fn write_to(&self, buf: &mut impl ::buffa::bytes::BufMut) {
477        #[allow(unused_imports)]
478        use ::buffa::Enumeration as _;
479        if !self.capture_group.is_empty() {
480            ::buffa::encoding::Tag::new(
481                    1u32,
482                    ::buffa::encoding::WireType::LengthDelimited,
483                )
484                .encode(buf);
485            ::buffa::types::encode_string(&self.capture_group, buf);
486        }
487        {
488            let val = self.encoding.to_i32();
489            if val != 0 {
490                ::buffa::encoding::Tag::new(2u32, ::buffa::encoding::WireType::Varint)
491                    .encode(buf);
492                ::buffa::types::encode_int32(val, buf);
493            }
494        }
495        self.__buffa_unknown_fields.write_to(buf);
496    }
497    fn merge_field(
498        &mut self,
499        tag: ::buffa::encoding::Tag,
500        buf: &mut impl ::buffa::bytes::Buf,
501        depth: u32,
502    ) -> ::core::result::Result<(), ::buffa::DecodeError> {
503        #[allow(unused_imports)]
504        use ::buffa::bytes::Buf as _;
505        #[allow(unused_imports)]
506        use ::buffa::Enumeration as _;
507        match tag.field_number() {
508            1u32 => {
509                if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
510                    return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
511                        field_number: 1u32,
512                        expected: 2u8,
513                        actual: tag.wire_type() as u8,
514                    });
515                }
516                ::buffa::types::merge_string(&mut self.capture_group, buf)?;
517            }
518            2u32 => {
519                if tag.wire_type() != ::buffa::encoding::WireType::Varint {
520                    return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
521                        field_number: 2u32,
522                        expected: 0u8,
523                        actual: tag.wire_type() as u8,
524                    });
525                }
526                self.encoding = ::buffa::EnumValue::from(
527                    ::buffa::types::decode_int32(buf)?,
528                );
529            }
530            _ => {
531                self.__buffa_unknown_fields
532                    .push(::buffa::encoding::decode_unknown_field(tag, buf, depth)?);
533            }
534        }
535        ::core::result::Result::Ok(())
536    }
537    fn cached_size(&self) -> u32 {
538        self.__buffa_cached_size.get()
539    }
540    fn clear(&mut self) {
541        self.capture_group.clear();
542        self.encoding = ::buffa::EnumValue::from(0);
543        self.__buffa_unknown_fields.clear();
544        self.__buffa_cached_size.set(0);
545    }
546}
547impl ::buffa::ExtensionSet for PolicyOrderBy {
548    const PROTO_FQN: &'static str = "store.compact.v1.PolicyOrderBy";
549    fn unknown_fields(&self) -> &::buffa::UnknownFields {
550        &self.__buffa_unknown_fields
551    }
552    fn unknown_fields_mut(&mut self) -> &mut ::buffa::UnknownFields {
553        &mut self.__buffa_unknown_fields
554    }
555}
556impl ::buffa::json_helpers::ProtoElemJson for PolicyOrderBy {
557    fn serialize_proto_json<S: ::serde::Serializer>(
558        v: &Self,
559        s: S,
560    ) -> ::core::result::Result<S::Ok, S::Error> {
561        ::serde::Serialize::serialize(v, s)
562    }
563    fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>(
564        d: D,
565    ) -> ::core::result::Result<Self, D::Error> {
566        <Self as ::serde::Deserialize>::deserialize(d)
567    }
568}
569#[doc(hidden)]
570pub const __POLICY_ORDER_BY_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry {
571    type_url: "type.googleapis.com/store.compact.v1.PolicyOrderBy",
572    to_json: ::buffa::type_registry::any_to_json::<PolicyOrderBy>,
573    from_json: ::buffa::type_registry::any_from_json::<PolicyOrderBy>,
574    is_wkt: false,
575};
576/// Defines the sort order within each group. The named capture group is
577/// extracted from the payload regex and decoded according to `encoding`.
578/// Required for `RetainKeepLatest` and threshold-based retain policies.
579#[derive(Clone, Debug, Default)]
580pub struct PolicyOrderByView<'a> {
581    /// Name of the capture group in `store.common.v1.MatchKey.payload_regex`
582    /// that provides the ordering value.
583    ///
584    /// Field 1: `capture_group`
585    pub capture_group: &'a str,
586    /// How to decode and compare the captured bytes.
587    ///
588    /// Field 2: `encoding`
589    pub encoding: ::buffa::EnumValue<PolicyOrderEncoding>,
590    pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
591}
592impl<'a> PolicyOrderByView<'a> {
593    /// Decode from `buf`, enforcing a recursion depth limit for nested messages.
594    ///
595    /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`]
596    /// and by generated sub-message decode arms with `depth - 1`.
597    ///
598    /// **Not part of the public API.** Named with a leading underscore to
599    /// signal that it is for generated-code use only.
600    #[doc(hidden)]
601    pub fn _decode_depth(
602        buf: &'a [u8],
603        depth: u32,
604    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
605        let mut view = Self::default();
606        view._merge_into_view(buf, depth)?;
607        ::core::result::Result::Ok(view)
608    }
609    /// Merge fields from `buf` into this view (proto merge semantics).
610    ///
611    /// Repeated fields append; singular fields last-wins; singular
612    /// MESSAGE fields merge recursively. Used by sub-message decode
613    /// arms when the same field appears multiple times on the wire.
614    ///
615    /// **Not part of the public API.**
616    #[doc(hidden)]
617    pub fn _merge_into_view(
618        &mut self,
619        buf: &'a [u8],
620        depth: u32,
621    ) -> ::core::result::Result<(), ::buffa::DecodeError> {
622        let _ = depth;
623        #[allow(unused_variables)]
624        let view = self;
625        let mut cur: &'a [u8] = buf;
626        while !cur.is_empty() {
627            let before_tag = cur;
628            let tag = ::buffa::encoding::Tag::decode(&mut cur)?;
629            match tag.field_number() {
630                1u32 => {
631                    if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
632                        return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
633                            field_number: 1u32,
634                            expected: 2u8,
635                            actual: tag.wire_type() as u8,
636                        });
637                    }
638                    view.capture_group = ::buffa::types::borrow_str(&mut cur)?;
639                }
640                2u32 => {
641                    if tag.wire_type() != ::buffa::encoding::WireType::Varint {
642                        return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
643                            field_number: 2u32,
644                            expected: 0u8,
645                            actual: tag.wire_type() as u8,
646                        });
647                    }
648                    view.encoding = ::buffa::EnumValue::from(
649                        ::buffa::types::decode_int32(&mut cur)?,
650                    );
651                }
652                _ => {
653                    ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?;
654                    let span_len = before_tag.len() - cur.len();
655                    view.__buffa_unknown_fields.push_raw(&before_tag[..span_len]);
656                }
657            }
658        }
659        ::core::result::Result::Ok(())
660    }
661}
662impl<'a> ::buffa::MessageView<'a> for PolicyOrderByView<'a> {
663    type Owned = PolicyOrderBy;
664    fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
665        Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT)
666    }
667    fn decode_view_with_limit(
668        buf: &'a [u8],
669        depth: u32,
670    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
671        Self::_decode_depth(buf, depth)
672    }
673    /// Convert this view to the owned message type.
674    #[allow(clippy::redundant_closure, clippy::useless_conversion)]
675    fn to_owned_message(&self) -> PolicyOrderBy {
676        #[allow(unused_imports)]
677        use ::buffa::alloc::string::ToString as _;
678        PolicyOrderBy {
679            capture_group: self.capture_group.to_string(),
680            encoding: self.encoding,
681            __buffa_unknown_fields: self
682                .__buffa_unknown_fields
683                .to_owned()
684                .unwrap_or_default()
685                .into(),
686            ..::core::default::Default::default()
687        }
688    }
689}
690unsafe impl ::buffa::DefaultViewInstance for PolicyOrderByView<'static> {
691    fn default_view_instance() -> &'static Self {
692        static VALUE: ::buffa::__private::OnceBox<PolicyOrderByView<'static>> = ::buffa::__private::OnceBox::new();
693        VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default()))
694    }
695}
696unsafe impl<'a> ::buffa::HasDefaultViewInstance for PolicyOrderByView<'a> {
697    type Static = PolicyOrderByView<'static>;
698}
699/// Retain the N entries with the highest order values within each group.
700/// Requires `PolicyOrderBy` to be set on the parent scope.
701#[derive(Clone, PartialEq, Default)]
702#[derive(::serde::Serialize, ::serde::Deserialize)]
703#[serde(default)]
704pub struct RetainKeepLatest {
705    /// Number of entries to keep per group. Must be \> 0.
706    ///
707    /// Field 1: `count`
708    #[serde(
709        rename = "count",
710        with = "::buffa::json_helpers::uint64",
711        skip_serializing_if = "::buffa::json_helpers::skip_if::is_zero_u64"
712    )]
713    pub count: u64,
714    #[serde(skip)]
715    #[doc(hidden)]
716    pub __buffa_unknown_fields: ::buffa::UnknownFields,
717    #[doc(hidden)]
718    #[serde(skip)]
719    pub __buffa_cached_size: ::buffa::__private::CachedSize,
720}
721impl ::core::fmt::Debug for RetainKeepLatest {
722    fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
723        f.debug_struct("RetainKeepLatest").field("count", &self.count).finish()
724    }
725}
726impl RetainKeepLatest {
727    /// Protobuf type URL for this message, for use with `Any::pack` and
728    /// `Any::unpack_if`.
729    ///
730    /// Format: `type.googleapis.com/<fully.qualified.TypeName>`
731    pub const TYPE_URL: &'static str = "type.googleapis.com/store.compact.v1.RetainKeepLatest";
732}
733unsafe impl ::buffa::DefaultInstance for RetainKeepLatest {
734    fn default_instance() -> &'static Self {
735        static VALUE: ::buffa::__private::OnceBox<RetainKeepLatest> = ::buffa::__private::OnceBox::new();
736        VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default()))
737    }
738}
739impl ::buffa::Message for RetainKeepLatest {
740    /// Returns the total encoded size in bytes.
741    ///
742    /// The result is a `u32`; the protobuf specification requires all
743    /// messages to fit within 2 GiB (2,147,483,647 bytes), so a
744    /// compliant message will never overflow this type.
745    fn compute_size(&self) -> u32 {
746        #[allow(unused_imports)]
747        use ::buffa::Enumeration as _;
748        let mut size = 0u32;
749        if self.count != 0u64 {
750            size += 1u32 + ::buffa::types::uint64_encoded_len(self.count) as u32;
751        }
752        size += self.__buffa_unknown_fields.encoded_len() as u32;
753        self.__buffa_cached_size.set(size);
754        size
755    }
756    fn write_to(&self, buf: &mut impl ::buffa::bytes::BufMut) {
757        #[allow(unused_imports)]
758        use ::buffa::Enumeration as _;
759        if self.count != 0u64 {
760            ::buffa::encoding::Tag::new(1u32, ::buffa::encoding::WireType::Varint)
761                .encode(buf);
762            ::buffa::types::encode_uint64(self.count, buf);
763        }
764        self.__buffa_unknown_fields.write_to(buf);
765    }
766    fn merge_field(
767        &mut self,
768        tag: ::buffa::encoding::Tag,
769        buf: &mut impl ::buffa::bytes::Buf,
770        depth: u32,
771    ) -> ::core::result::Result<(), ::buffa::DecodeError> {
772        #[allow(unused_imports)]
773        use ::buffa::bytes::Buf as _;
774        #[allow(unused_imports)]
775        use ::buffa::Enumeration as _;
776        match tag.field_number() {
777            1u32 => {
778                if tag.wire_type() != ::buffa::encoding::WireType::Varint {
779                    return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
780                        field_number: 1u32,
781                        expected: 0u8,
782                        actual: tag.wire_type() as u8,
783                    });
784                }
785                self.count = ::buffa::types::decode_uint64(buf)?;
786            }
787            _ => {
788                self.__buffa_unknown_fields
789                    .push(::buffa::encoding::decode_unknown_field(tag, buf, depth)?);
790            }
791        }
792        ::core::result::Result::Ok(())
793    }
794    fn cached_size(&self) -> u32 {
795        self.__buffa_cached_size.get()
796    }
797    fn clear(&mut self) {
798        self.count = 0u64;
799        self.__buffa_unknown_fields.clear();
800        self.__buffa_cached_size.set(0);
801    }
802}
803impl ::buffa::ExtensionSet for RetainKeepLatest {
804    const PROTO_FQN: &'static str = "store.compact.v1.RetainKeepLatest";
805    fn unknown_fields(&self) -> &::buffa::UnknownFields {
806        &self.__buffa_unknown_fields
807    }
808    fn unknown_fields_mut(&mut self) -> &mut ::buffa::UnknownFields {
809        &mut self.__buffa_unknown_fields
810    }
811}
812impl ::buffa::json_helpers::ProtoElemJson for RetainKeepLatest {
813    fn serialize_proto_json<S: ::serde::Serializer>(
814        v: &Self,
815        s: S,
816    ) -> ::core::result::Result<S::Ok, S::Error> {
817        ::serde::Serialize::serialize(v, s)
818    }
819    fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>(
820        d: D,
821    ) -> ::core::result::Result<Self, D::Error> {
822        <Self as ::serde::Deserialize>::deserialize(d)
823    }
824}
825#[doc(hidden)]
826pub const __RETAIN_KEEP_LATEST_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry {
827    type_url: "type.googleapis.com/store.compact.v1.RetainKeepLatest",
828    to_json: ::buffa::type_registry::any_to_json::<RetainKeepLatest>,
829    from_json: ::buffa::type_registry::any_from_json::<RetainKeepLatest>,
830    is_wkt: false,
831};
832/// Retain the N entries with the highest order values within each group.
833/// Requires `PolicyOrderBy` to be set on the parent scope.
834#[derive(Clone, Debug, Default)]
835pub struct RetainKeepLatestView<'a> {
836    /// Number of entries to keep per group. Must be \> 0.
837    ///
838    /// Field 1: `count`
839    pub count: u64,
840    pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
841}
842impl<'a> RetainKeepLatestView<'a> {
843    /// Decode from `buf`, enforcing a recursion depth limit for nested messages.
844    ///
845    /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`]
846    /// and by generated sub-message decode arms with `depth - 1`.
847    ///
848    /// **Not part of the public API.** Named with a leading underscore to
849    /// signal that it is for generated-code use only.
850    #[doc(hidden)]
851    pub fn _decode_depth(
852        buf: &'a [u8],
853        depth: u32,
854    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
855        let mut view = Self::default();
856        view._merge_into_view(buf, depth)?;
857        ::core::result::Result::Ok(view)
858    }
859    /// Merge fields from `buf` into this view (proto merge semantics).
860    ///
861    /// Repeated fields append; singular fields last-wins; singular
862    /// MESSAGE fields merge recursively. Used by sub-message decode
863    /// arms when the same field appears multiple times on the wire.
864    ///
865    /// **Not part of the public API.**
866    #[doc(hidden)]
867    pub fn _merge_into_view(
868        &mut self,
869        buf: &'a [u8],
870        depth: u32,
871    ) -> ::core::result::Result<(), ::buffa::DecodeError> {
872        let _ = depth;
873        #[allow(unused_variables)]
874        let view = self;
875        let mut cur: &'a [u8] = buf;
876        while !cur.is_empty() {
877            let before_tag = cur;
878            let tag = ::buffa::encoding::Tag::decode(&mut cur)?;
879            match tag.field_number() {
880                1u32 => {
881                    if tag.wire_type() != ::buffa::encoding::WireType::Varint {
882                        return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
883                            field_number: 1u32,
884                            expected: 0u8,
885                            actual: tag.wire_type() as u8,
886                        });
887                    }
888                    view.count = ::buffa::types::decode_uint64(&mut cur)?;
889                }
890                _ => {
891                    ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?;
892                    let span_len = before_tag.len() - cur.len();
893                    view.__buffa_unknown_fields.push_raw(&before_tag[..span_len]);
894                }
895            }
896        }
897        ::core::result::Result::Ok(())
898    }
899}
900impl<'a> ::buffa::MessageView<'a> for RetainKeepLatestView<'a> {
901    type Owned = RetainKeepLatest;
902    fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
903        Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT)
904    }
905    fn decode_view_with_limit(
906        buf: &'a [u8],
907        depth: u32,
908    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
909        Self::_decode_depth(buf, depth)
910    }
911    /// Convert this view to the owned message type.
912    #[allow(clippy::redundant_closure, clippy::useless_conversion)]
913    fn to_owned_message(&self) -> RetainKeepLatest {
914        #[allow(unused_imports)]
915        use ::buffa::alloc::string::ToString as _;
916        RetainKeepLatest {
917            count: self.count,
918            __buffa_unknown_fields: self
919                .__buffa_unknown_fields
920                .to_owned()
921                .unwrap_or_default()
922                .into(),
923            ..::core::default::Default::default()
924        }
925    }
926}
927unsafe impl ::buffa::DefaultViewInstance for RetainKeepLatestView<'static> {
928    fn default_view_instance() -> &'static Self {
929        static VALUE: ::buffa::__private::OnceBox<RetainKeepLatestView<'static>> = ::buffa::__private::OnceBox::new();
930        VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default()))
931    }
932}
933unsafe impl<'a> ::buffa::HasDefaultViewInstance for RetainKeepLatestView<'a> {
934    type Static = RetainKeepLatestView<'static>;
935}
936/// Delete entries whose order value is less than or equal to `threshold`.
937/// For `UserKeysScope` requires `PolicyOrderBy` with u64_be encoding.
938#[derive(Clone, PartialEq, Default)]
939#[derive(::serde::Serialize, ::serde::Deserialize)]
940#[serde(default)]
941pub struct RetainGreaterThan {
942    /// Entries with order value \> this threshold are retained.
943    ///
944    /// Field 1: `threshold`
945    #[serde(
946        rename = "threshold",
947        with = "::buffa::json_helpers::uint64",
948        skip_serializing_if = "::buffa::json_helpers::skip_if::is_zero_u64"
949    )]
950    pub threshold: u64,
951    #[serde(skip)]
952    #[doc(hidden)]
953    pub __buffa_unknown_fields: ::buffa::UnknownFields,
954    #[doc(hidden)]
955    #[serde(skip)]
956    pub __buffa_cached_size: ::buffa::__private::CachedSize,
957}
958impl ::core::fmt::Debug for RetainGreaterThan {
959    fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
960        f.debug_struct("RetainGreaterThan").field("threshold", &self.threshold).finish()
961    }
962}
963impl RetainGreaterThan {
964    /// Protobuf type URL for this message, for use with `Any::pack` and
965    /// `Any::unpack_if`.
966    ///
967    /// Format: `type.googleapis.com/<fully.qualified.TypeName>`
968    pub const TYPE_URL: &'static str = "type.googleapis.com/store.compact.v1.RetainGreaterThan";
969}
970unsafe impl ::buffa::DefaultInstance for RetainGreaterThan {
971    fn default_instance() -> &'static Self {
972        static VALUE: ::buffa::__private::OnceBox<RetainGreaterThan> = ::buffa::__private::OnceBox::new();
973        VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default()))
974    }
975}
976impl ::buffa::Message for RetainGreaterThan {
977    /// Returns the total encoded size in bytes.
978    ///
979    /// The result is a `u32`; the protobuf specification requires all
980    /// messages to fit within 2 GiB (2,147,483,647 bytes), so a
981    /// compliant message will never overflow this type.
982    fn compute_size(&self) -> u32 {
983        #[allow(unused_imports)]
984        use ::buffa::Enumeration as _;
985        let mut size = 0u32;
986        if self.threshold != 0u64 {
987            size += 1u32 + ::buffa::types::uint64_encoded_len(self.threshold) as u32;
988        }
989        size += self.__buffa_unknown_fields.encoded_len() as u32;
990        self.__buffa_cached_size.set(size);
991        size
992    }
993    fn write_to(&self, buf: &mut impl ::buffa::bytes::BufMut) {
994        #[allow(unused_imports)]
995        use ::buffa::Enumeration as _;
996        if self.threshold != 0u64 {
997            ::buffa::encoding::Tag::new(1u32, ::buffa::encoding::WireType::Varint)
998                .encode(buf);
999            ::buffa::types::encode_uint64(self.threshold, buf);
1000        }
1001        self.__buffa_unknown_fields.write_to(buf);
1002    }
1003    fn merge_field(
1004        &mut self,
1005        tag: ::buffa::encoding::Tag,
1006        buf: &mut impl ::buffa::bytes::Buf,
1007        depth: u32,
1008    ) -> ::core::result::Result<(), ::buffa::DecodeError> {
1009        #[allow(unused_imports)]
1010        use ::buffa::bytes::Buf as _;
1011        #[allow(unused_imports)]
1012        use ::buffa::Enumeration as _;
1013        match tag.field_number() {
1014            1u32 => {
1015                if tag.wire_type() != ::buffa::encoding::WireType::Varint {
1016                    return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
1017                        field_number: 1u32,
1018                        expected: 0u8,
1019                        actual: tag.wire_type() as u8,
1020                    });
1021                }
1022                self.threshold = ::buffa::types::decode_uint64(buf)?;
1023            }
1024            _ => {
1025                self.__buffa_unknown_fields
1026                    .push(::buffa::encoding::decode_unknown_field(tag, buf, depth)?);
1027            }
1028        }
1029        ::core::result::Result::Ok(())
1030    }
1031    fn cached_size(&self) -> u32 {
1032        self.__buffa_cached_size.get()
1033    }
1034    fn clear(&mut self) {
1035        self.threshold = 0u64;
1036        self.__buffa_unknown_fields.clear();
1037        self.__buffa_cached_size.set(0);
1038    }
1039}
1040impl ::buffa::ExtensionSet for RetainGreaterThan {
1041    const PROTO_FQN: &'static str = "store.compact.v1.RetainGreaterThan";
1042    fn unknown_fields(&self) -> &::buffa::UnknownFields {
1043        &self.__buffa_unknown_fields
1044    }
1045    fn unknown_fields_mut(&mut self) -> &mut ::buffa::UnknownFields {
1046        &mut self.__buffa_unknown_fields
1047    }
1048}
1049impl ::buffa::json_helpers::ProtoElemJson for RetainGreaterThan {
1050    fn serialize_proto_json<S: ::serde::Serializer>(
1051        v: &Self,
1052        s: S,
1053    ) -> ::core::result::Result<S::Ok, S::Error> {
1054        ::serde::Serialize::serialize(v, s)
1055    }
1056    fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>(
1057        d: D,
1058    ) -> ::core::result::Result<Self, D::Error> {
1059        <Self as ::serde::Deserialize>::deserialize(d)
1060    }
1061}
1062#[doc(hidden)]
1063pub const __RETAIN_GREATER_THAN_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry {
1064    type_url: "type.googleapis.com/store.compact.v1.RetainGreaterThan",
1065    to_json: ::buffa::type_registry::any_to_json::<RetainGreaterThan>,
1066    from_json: ::buffa::type_registry::any_from_json::<RetainGreaterThan>,
1067    is_wkt: false,
1068};
1069/// Delete entries whose order value is less than or equal to `threshold`.
1070/// For `UserKeysScope` requires `PolicyOrderBy` with u64_be encoding.
1071#[derive(Clone, Debug, Default)]
1072pub struct RetainGreaterThanView<'a> {
1073    /// Entries with order value \> this threshold are retained.
1074    ///
1075    /// Field 1: `threshold`
1076    pub threshold: u64,
1077    pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
1078}
1079impl<'a> RetainGreaterThanView<'a> {
1080    /// Decode from `buf`, enforcing a recursion depth limit for nested messages.
1081    ///
1082    /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`]
1083    /// and by generated sub-message decode arms with `depth - 1`.
1084    ///
1085    /// **Not part of the public API.** Named with a leading underscore to
1086    /// signal that it is for generated-code use only.
1087    #[doc(hidden)]
1088    pub fn _decode_depth(
1089        buf: &'a [u8],
1090        depth: u32,
1091    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
1092        let mut view = Self::default();
1093        view._merge_into_view(buf, depth)?;
1094        ::core::result::Result::Ok(view)
1095    }
1096    /// Merge fields from `buf` into this view (proto merge semantics).
1097    ///
1098    /// Repeated fields append; singular fields last-wins; singular
1099    /// MESSAGE fields merge recursively. Used by sub-message decode
1100    /// arms when the same field appears multiple times on the wire.
1101    ///
1102    /// **Not part of the public API.**
1103    #[doc(hidden)]
1104    pub fn _merge_into_view(
1105        &mut self,
1106        buf: &'a [u8],
1107        depth: u32,
1108    ) -> ::core::result::Result<(), ::buffa::DecodeError> {
1109        let _ = depth;
1110        #[allow(unused_variables)]
1111        let view = self;
1112        let mut cur: &'a [u8] = buf;
1113        while !cur.is_empty() {
1114            let before_tag = cur;
1115            let tag = ::buffa::encoding::Tag::decode(&mut cur)?;
1116            match tag.field_number() {
1117                1u32 => {
1118                    if tag.wire_type() != ::buffa::encoding::WireType::Varint {
1119                        return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
1120                            field_number: 1u32,
1121                            expected: 0u8,
1122                            actual: tag.wire_type() as u8,
1123                        });
1124                    }
1125                    view.threshold = ::buffa::types::decode_uint64(&mut cur)?;
1126                }
1127                _ => {
1128                    ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?;
1129                    let span_len = before_tag.len() - cur.len();
1130                    view.__buffa_unknown_fields.push_raw(&before_tag[..span_len]);
1131                }
1132            }
1133        }
1134        ::core::result::Result::Ok(())
1135    }
1136}
1137impl<'a> ::buffa::MessageView<'a> for RetainGreaterThanView<'a> {
1138    type Owned = RetainGreaterThan;
1139    fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
1140        Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT)
1141    }
1142    fn decode_view_with_limit(
1143        buf: &'a [u8],
1144        depth: u32,
1145    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
1146        Self::_decode_depth(buf, depth)
1147    }
1148    /// Convert this view to the owned message type.
1149    #[allow(clippy::redundant_closure, clippy::useless_conversion)]
1150    fn to_owned_message(&self) -> RetainGreaterThan {
1151        #[allow(unused_imports)]
1152        use ::buffa::alloc::string::ToString as _;
1153        RetainGreaterThan {
1154            threshold: self.threshold,
1155            __buffa_unknown_fields: self
1156                .__buffa_unknown_fields
1157                .to_owned()
1158                .unwrap_or_default()
1159                .into(),
1160            ..::core::default::Default::default()
1161        }
1162    }
1163}
1164unsafe impl ::buffa::DefaultViewInstance for RetainGreaterThanView<'static> {
1165    fn default_view_instance() -> &'static Self {
1166        static VALUE: ::buffa::__private::OnceBox<RetainGreaterThanView<'static>> = ::buffa::__private::OnceBox::new();
1167        VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default()))
1168    }
1169}
1170unsafe impl<'a> ::buffa::HasDefaultViewInstance for RetainGreaterThanView<'a> {
1171    type Static = RetainGreaterThanView<'static>;
1172}
1173/// Delete entries whose order value is strictly less than `threshold`.
1174/// For `UserKeysScope` requires `PolicyOrderBy` with u64_be encoding.
1175#[derive(Clone, PartialEq, Default)]
1176#[derive(::serde::Serialize, ::serde::Deserialize)]
1177#[serde(default)]
1178pub struct RetainGreaterThanOrEqual {
1179    /// Entries with order value \>= this threshold are retained.
1180    ///
1181    /// Field 1: `threshold`
1182    #[serde(
1183        rename = "threshold",
1184        with = "::buffa::json_helpers::uint64",
1185        skip_serializing_if = "::buffa::json_helpers::skip_if::is_zero_u64"
1186    )]
1187    pub threshold: u64,
1188    #[serde(skip)]
1189    #[doc(hidden)]
1190    pub __buffa_unknown_fields: ::buffa::UnknownFields,
1191    #[doc(hidden)]
1192    #[serde(skip)]
1193    pub __buffa_cached_size: ::buffa::__private::CachedSize,
1194}
1195impl ::core::fmt::Debug for RetainGreaterThanOrEqual {
1196    fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
1197        f.debug_struct("RetainGreaterThanOrEqual")
1198            .field("threshold", &self.threshold)
1199            .finish()
1200    }
1201}
1202impl RetainGreaterThanOrEqual {
1203    /// Protobuf type URL for this message, for use with `Any::pack` and
1204    /// `Any::unpack_if`.
1205    ///
1206    /// Format: `type.googleapis.com/<fully.qualified.TypeName>`
1207    pub const TYPE_URL: &'static str = "type.googleapis.com/store.compact.v1.RetainGreaterThanOrEqual";
1208}
1209unsafe impl ::buffa::DefaultInstance for RetainGreaterThanOrEqual {
1210    fn default_instance() -> &'static Self {
1211        static VALUE: ::buffa::__private::OnceBox<RetainGreaterThanOrEqual> = ::buffa::__private::OnceBox::new();
1212        VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default()))
1213    }
1214}
1215impl ::buffa::Message for RetainGreaterThanOrEqual {
1216    /// Returns the total encoded size in bytes.
1217    ///
1218    /// The result is a `u32`; the protobuf specification requires all
1219    /// messages to fit within 2 GiB (2,147,483,647 bytes), so a
1220    /// compliant message will never overflow this type.
1221    fn compute_size(&self) -> u32 {
1222        #[allow(unused_imports)]
1223        use ::buffa::Enumeration as _;
1224        let mut size = 0u32;
1225        if self.threshold != 0u64 {
1226            size += 1u32 + ::buffa::types::uint64_encoded_len(self.threshold) as u32;
1227        }
1228        size += self.__buffa_unknown_fields.encoded_len() as u32;
1229        self.__buffa_cached_size.set(size);
1230        size
1231    }
1232    fn write_to(&self, buf: &mut impl ::buffa::bytes::BufMut) {
1233        #[allow(unused_imports)]
1234        use ::buffa::Enumeration as _;
1235        if self.threshold != 0u64 {
1236            ::buffa::encoding::Tag::new(1u32, ::buffa::encoding::WireType::Varint)
1237                .encode(buf);
1238            ::buffa::types::encode_uint64(self.threshold, buf);
1239        }
1240        self.__buffa_unknown_fields.write_to(buf);
1241    }
1242    fn merge_field(
1243        &mut self,
1244        tag: ::buffa::encoding::Tag,
1245        buf: &mut impl ::buffa::bytes::Buf,
1246        depth: u32,
1247    ) -> ::core::result::Result<(), ::buffa::DecodeError> {
1248        #[allow(unused_imports)]
1249        use ::buffa::bytes::Buf as _;
1250        #[allow(unused_imports)]
1251        use ::buffa::Enumeration as _;
1252        match tag.field_number() {
1253            1u32 => {
1254                if tag.wire_type() != ::buffa::encoding::WireType::Varint {
1255                    return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
1256                        field_number: 1u32,
1257                        expected: 0u8,
1258                        actual: tag.wire_type() as u8,
1259                    });
1260                }
1261                self.threshold = ::buffa::types::decode_uint64(buf)?;
1262            }
1263            _ => {
1264                self.__buffa_unknown_fields
1265                    .push(::buffa::encoding::decode_unknown_field(tag, buf, depth)?);
1266            }
1267        }
1268        ::core::result::Result::Ok(())
1269    }
1270    fn cached_size(&self) -> u32 {
1271        self.__buffa_cached_size.get()
1272    }
1273    fn clear(&mut self) {
1274        self.threshold = 0u64;
1275        self.__buffa_unknown_fields.clear();
1276        self.__buffa_cached_size.set(0);
1277    }
1278}
1279impl ::buffa::ExtensionSet for RetainGreaterThanOrEqual {
1280    const PROTO_FQN: &'static str = "store.compact.v1.RetainGreaterThanOrEqual";
1281    fn unknown_fields(&self) -> &::buffa::UnknownFields {
1282        &self.__buffa_unknown_fields
1283    }
1284    fn unknown_fields_mut(&mut self) -> &mut ::buffa::UnknownFields {
1285        &mut self.__buffa_unknown_fields
1286    }
1287}
1288impl ::buffa::json_helpers::ProtoElemJson for RetainGreaterThanOrEqual {
1289    fn serialize_proto_json<S: ::serde::Serializer>(
1290        v: &Self,
1291        s: S,
1292    ) -> ::core::result::Result<S::Ok, S::Error> {
1293        ::serde::Serialize::serialize(v, s)
1294    }
1295    fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>(
1296        d: D,
1297    ) -> ::core::result::Result<Self, D::Error> {
1298        <Self as ::serde::Deserialize>::deserialize(d)
1299    }
1300}
1301#[doc(hidden)]
1302pub const __RETAIN_GREATER_THAN_OR_EQUAL_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry {
1303    type_url: "type.googleapis.com/store.compact.v1.RetainGreaterThanOrEqual",
1304    to_json: ::buffa::type_registry::any_to_json::<RetainGreaterThanOrEqual>,
1305    from_json: ::buffa::type_registry::any_from_json::<RetainGreaterThanOrEqual>,
1306    is_wkt: false,
1307};
1308/// Delete entries whose order value is strictly less than `threshold`.
1309/// For `UserKeysScope` requires `PolicyOrderBy` with u64_be encoding.
1310#[derive(Clone, Debug, Default)]
1311pub struct RetainGreaterThanOrEqualView<'a> {
1312    /// Entries with order value \>= this threshold are retained.
1313    ///
1314    /// Field 1: `threshold`
1315    pub threshold: u64,
1316    pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
1317}
1318impl<'a> RetainGreaterThanOrEqualView<'a> {
1319    /// Decode from `buf`, enforcing a recursion depth limit for nested messages.
1320    ///
1321    /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`]
1322    /// and by generated sub-message decode arms with `depth - 1`.
1323    ///
1324    /// **Not part of the public API.** Named with a leading underscore to
1325    /// signal that it is for generated-code use only.
1326    #[doc(hidden)]
1327    pub fn _decode_depth(
1328        buf: &'a [u8],
1329        depth: u32,
1330    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
1331        let mut view = Self::default();
1332        view._merge_into_view(buf, depth)?;
1333        ::core::result::Result::Ok(view)
1334    }
1335    /// Merge fields from `buf` into this view (proto merge semantics).
1336    ///
1337    /// Repeated fields append; singular fields last-wins; singular
1338    /// MESSAGE fields merge recursively. Used by sub-message decode
1339    /// arms when the same field appears multiple times on the wire.
1340    ///
1341    /// **Not part of the public API.**
1342    #[doc(hidden)]
1343    pub fn _merge_into_view(
1344        &mut self,
1345        buf: &'a [u8],
1346        depth: u32,
1347    ) -> ::core::result::Result<(), ::buffa::DecodeError> {
1348        let _ = depth;
1349        #[allow(unused_variables)]
1350        let view = self;
1351        let mut cur: &'a [u8] = buf;
1352        while !cur.is_empty() {
1353            let before_tag = cur;
1354            let tag = ::buffa::encoding::Tag::decode(&mut cur)?;
1355            match tag.field_number() {
1356                1u32 => {
1357                    if tag.wire_type() != ::buffa::encoding::WireType::Varint {
1358                        return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
1359                            field_number: 1u32,
1360                            expected: 0u8,
1361                            actual: tag.wire_type() as u8,
1362                        });
1363                    }
1364                    view.threshold = ::buffa::types::decode_uint64(&mut cur)?;
1365                }
1366                _ => {
1367                    ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?;
1368                    let span_len = before_tag.len() - cur.len();
1369                    view.__buffa_unknown_fields.push_raw(&before_tag[..span_len]);
1370                }
1371            }
1372        }
1373        ::core::result::Result::Ok(())
1374    }
1375}
1376impl<'a> ::buffa::MessageView<'a> for RetainGreaterThanOrEqualView<'a> {
1377    type Owned = RetainGreaterThanOrEqual;
1378    fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
1379        Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT)
1380    }
1381    fn decode_view_with_limit(
1382        buf: &'a [u8],
1383        depth: u32,
1384    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
1385        Self::_decode_depth(buf, depth)
1386    }
1387    /// Convert this view to the owned message type.
1388    #[allow(clippy::redundant_closure, clippy::useless_conversion)]
1389    fn to_owned_message(&self) -> RetainGreaterThanOrEqual {
1390        #[allow(unused_imports)]
1391        use ::buffa::alloc::string::ToString as _;
1392        RetainGreaterThanOrEqual {
1393            threshold: self.threshold,
1394            __buffa_unknown_fields: self
1395                .__buffa_unknown_fields
1396                .to_owned()
1397                .unwrap_or_default()
1398                .into(),
1399            ..::core::default::Default::default()
1400        }
1401    }
1402}
1403unsafe impl ::buffa::DefaultViewInstance for RetainGreaterThanOrEqualView<'static> {
1404    fn default_view_instance() -> &'static Self {
1405        static VALUE: ::buffa::__private::OnceBox<
1406            RetainGreaterThanOrEqualView<'static>,
1407        > = ::buffa::__private::OnceBox::new();
1408        VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default()))
1409    }
1410}
1411unsafe impl<'a> ::buffa::HasDefaultViewInstance for RetainGreaterThanOrEqualView<'a> {
1412    type Static = RetainGreaterThanOrEqualView<'static>;
1413}
1414/// Delete all matched entries unconditionally.
1415#[derive(Clone, PartialEq, Default)]
1416#[derive(::serde::Serialize, ::serde::Deserialize)]
1417#[serde(default)]
1418pub struct RetainDropAll {
1419    #[serde(skip)]
1420    #[doc(hidden)]
1421    pub __buffa_unknown_fields: ::buffa::UnknownFields,
1422    #[doc(hidden)]
1423    #[serde(skip)]
1424    pub __buffa_cached_size: ::buffa::__private::CachedSize,
1425}
1426impl ::core::fmt::Debug for RetainDropAll {
1427    fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
1428        f.debug_struct("RetainDropAll").finish()
1429    }
1430}
1431impl RetainDropAll {
1432    /// Protobuf type URL for this message, for use with `Any::pack` and
1433    /// `Any::unpack_if`.
1434    ///
1435    /// Format: `type.googleapis.com/<fully.qualified.TypeName>`
1436    pub const TYPE_URL: &'static str = "type.googleapis.com/store.compact.v1.RetainDropAll";
1437}
1438unsafe impl ::buffa::DefaultInstance for RetainDropAll {
1439    fn default_instance() -> &'static Self {
1440        static VALUE: ::buffa::__private::OnceBox<RetainDropAll> = ::buffa::__private::OnceBox::new();
1441        VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default()))
1442    }
1443}
1444impl ::buffa::Message for RetainDropAll {
1445    /// Returns the total encoded size in bytes.
1446    ///
1447    /// The result is a `u32`; the protobuf specification requires all
1448    /// messages to fit within 2 GiB (2,147,483,647 bytes), so a
1449    /// compliant message will never overflow this type.
1450    fn compute_size(&self) -> u32 {
1451        #[allow(unused_imports)]
1452        use ::buffa::Enumeration as _;
1453        let mut size = 0u32;
1454        size += self.__buffa_unknown_fields.encoded_len() as u32;
1455        self.__buffa_cached_size.set(size);
1456        size
1457    }
1458    fn write_to(&self, buf: &mut impl ::buffa::bytes::BufMut) {
1459        #[allow(unused_imports)]
1460        use ::buffa::Enumeration as _;
1461        self.__buffa_unknown_fields.write_to(buf);
1462    }
1463    fn merge_field(
1464        &mut self,
1465        tag: ::buffa::encoding::Tag,
1466        buf: &mut impl ::buffa::bytes::Buf,
1467        depth: u32,
1468    ) -> ::core::result::Result<(), ::buffa::DecodeError> {
1469        #[allow(unused_imports)]
1470        use ::buffa::bytes::Buf as _;
1471        #[allow(unused_imports)]
1472        use ::buffa::Enumeration as _;
1473        match tag.field_number() {
1474            _ => {
1475                self.__buffa_unknown_fields
1476                    .push(::buffa::encoding::decode_unknown_field(tag, buf, depth)?);
1477            }
1478        }
1479        ::core::result::Result::Ok(())
1480    }
1481    fn cached_size(&self) -> u32 {
1482        self.__buffa_cached_size.get()
1483    }
1484    fn clear(&mut self) {
1485        self.__buffa_unknown_fields.clear();
1486        self.__buffa_cached_size.set(0);
1487    }
1488}
1489impl ::buffa::ExtensionSet for RetainDropAll {
1490    const PROTO_FQN: &'static str = "store.compact.v1.RetainDropAll";
1491    fn unknown_fields(&self) -> &::buffa::UnknownFields {
1492        &self.__buffa_unknown_fields
1493    }
1494    fn unknown_fields_mut(&mut self) -> &mut ::buffa::UnknownFields {
1495        &mut self.__buffa_unknown_fields
1496    }
1497}
1498impl ::buffa::json_helpers::ProtoElemJson for RetainDropAll {
1499    fn serialize_proto_json<S: ::serde::Serializer>(
1500        v: &Self,
1501        s: S,
1502    ) -> ::core::result::Result<S::Ok, S::Error> {
1503        ::serde::Serialize::serialize(v, s)
1504    }
1505    fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>(
1506        d: D,
1507    ) -> ::core::result::Result<Self, D::Error> {
1508        <Self as ::serde::Deserialize>::deserialize(d)
1509    }
1510}
1511#[doc(hidden)]
1512pub const __RETAIN_DROP_ALL_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry {
1513    type_url: "type.googleapis.com/store.compact.v1.RetainDropAll",
1514    to_json: ::buffa::type_registry::any_to_json::<RetainDropAll>,
1515    from_json: ::buffa::type_registry::any_from_json::<RetainDropAll>,
1516    is_wkt: false,
1517};
1518/// Delete all matched entries unconditionally.
1519#[derive(Clone, Debug, Default)]
1520pub struct RetainDropAllView<'a> {
1521    pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
1522}
1523impl<'a> RetainDropAllView<'a> {
1524    /// Decode from `buf`, enforcing a recursion depth limit for nested messages.
1525    ///
1526    /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`]
1527    /// and by generated sub-message decode arms with `depth - 1`.
1528    ///
1529    /// **Not part of the public API.** Named with a leading underscore to
1530    /// signal that it is for generated-code use only.
1531    #[doc(hidden)]
1532    pub fn _decode_depth(
1533        buf: &'a [u8],
1534        depth: u32,
1535    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
1536        let mut view = Self::default();
1537        view._merge_into_view(buf, depth)?;
1538        ::core::result::Result::Ok(view)
1539    }
1540    /// Merge fields from `buf` into this view (proto merge semantics).
1541    ///
1542    /// Repeated fields append; singular fields last-wins; singular
1543    /// MESSAGE fields merge recursively. Used by sub-message decode
1544    /// arms when the same field appears multiple times on the wire.
1545    ///
1546    /// **Not part of the public API.**
1547    #[doc(hidden)]
1548    pub fn _merge_into_view(
1549        &mut self,
1550        buf: &'a [u8],
1551        depth: u32,
1552    ) -> ::core::result::Result<(), ::buffa::DecodeError> {
1553        let _ = depth;
1554        #[allow(unused_variables)]
1555        let view = self;
1556        let mut cur: &'a [u8] = buf;
1557        while !cur.is_empty() {
1558            let before_tag = cur;
1559            let tag = ::buffa::encoding::Tag::decode(&mut cur)?;
1560            match tag.field_number() {
1561                _ => {
1562                    ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?;
1563                    let span_len = before_tag.len() - cur.len();
1564                    view.__buffa_unknown_fields.push_raw(&before_tag[..span_len]);
1565                }
1566            }
1567        }
1568        ::core::result::Result::Ok(())
1569    }
1570}
1571impl<'a> ::buffa::MessageView<'a> for RetainDropAllView<'a> {
1572    type Owned = RetainDropAll;
1573    fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
1574        Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT)
1575    }
1576    fn decode_view_with_limit(
1577        buf: &'a [u8],
1578        depth: u32,
1579    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
1580        Self::_decode_depth(buf, depth)
1581    }
1582    /// Convert this view to the owned message type.
1583    #[allow(clippy::redundant_closure, clippy::useless_conversion)]
1584    fn to_owned_message(&self) -> RetainDropAll {
1585        #[allow(unused_imports)]
1586        use ::buffa::alloc::string::ToString as _;
1587        RetainDropAll {
1588            __buffa_unknown_fields: self
1589                .__buffa_unknown_fields
1590                .to_owned()
1591                .unwrap_or_default()
1592                .into(),
1593            ..::core::default::Default::default()
1594        }
1595    }
1596}
1597unsafe impl ::buffa::DefaultViewInstance for RetainDropAllView<'static> {
1598    fn default_view_instance() -> &'static Self {
1599        static VALUE: ::buffa::__private::OnceBox<RetainDropAllView<'static>> = ::buffa::__private::OnceBox::new();
1600        VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default()))
1601    }
1602}
1603unsafe impl<'a> ::buffa::HasDefaultViewInstance for RetainDropAllView<'a> {
1604    type Static = RetainDropAllView<'static>;
1605}
1606/// Selects which entries survive pruning within each group.
1607#[derive(Clone, PartialEq, Default)]
1608#[derive(::serde::Serialize)]
1609#[serde(default)]
1610pub struct PolicyRetain {
1611    #[serde(flatten)]
1612    pub kind: Option<policy_retain::Kind>,
1613    #[serde(skip)]
1614    #[doc(hidden)]
1615    pub __buffa_unknown_fields: ::buffa::UnknownFields,
1616    #[doc(hidden)]
1617    #[serde(skip)]
1618    pub __buffa_cached_size: ::buffa::__private::CachedSize,
1619}
1620impl ::core::fmt::Debug for PolicyRetain {
1621    fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
1622        f.debug_struct("PolicyRetain").field("kind", &self.kind).finish()
1623    }
1624}
1625impl PolicyRetain {
1626    /// Protobuf type URL for this message, for use with `Any::pack` and
1627    /// `Any::unpack_if`.
1628    ///
1629    /// Format: `type.googleapis.com/<fully.qualified.TypeName>`
1630    pub const TYPE_URL: &'static str = "type.googleapis.com/store.compact.v1.PolicyRetain";
1631}
1632unsafe impl ::buffa::DefaultInstance for PolicyRetain {
1633    fn default_instance() -> &'static Self {
1634        static VALUE: ::buffa::__private::OnceBox<PolicyRetain> = ::buffa::__private::OnceBox::new();
1635        VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default()))
1636    }
1637}
1638impl ::buffa::Message for PolicyRetain {
1639    /// Returns the total encoded size in bytes.
1640    ///
1641    /// The result is a `u32`; the protobuf specification requires all
1642    /// messages to fit within 2 GiB (2,147,483,647 bytes), so a
1643    /// compliant message will never overflow this type.
1644    fn compute_size(&self) -> u32 {
1645        #[allow(unused_imports)]
1646        use ::buffa::Enumeration as _;
1647        let mut size = 0u32;
1648        if let ::core::option::Option::Some(ref v) = self.kind {
1649            match v {
1650                policy_retain::Kind::KeepLatest(x) => {
1651                    let inner = x.compute_size();
1652                    size
1653                        += 1u32 + ::buffa::encoding::varint_len(inner as u64) as u32
1654                            + inner;
1655                }
1656                policy_retain::Kind::GreaterThan(x) => {
1657                    let inner = x.compute_size();
1658                    size
1659                        += 1u32 + ::buffa::encoding::varint_len(inner as u64) as u32
1660                            + inner;
1661                }
1662                policy_retain::Kind::GreaterThanOrEqual(x) => {
1663                    let inner = x.compute_size();
1664                    size
1665                        += 1u32 + ::buffa::encoding::varint_len(inner as u64) as u32
1666                            + inner;
1667                }
1668                policy_retain::Kind::DropAll(x) => {
1669                    let inner = x.compute_size();
1670                    size
1671                        += 1u32 + ::buffa::encoding::varint_len(inner as u64) as u32
1672                            + inner;
1673                }
1674            }
1675        }
1676        size += self.__buffa_unknown_fields.encoded_len() as u32;
1677        self.__buffa_cached_size.set(size);
1678        size
1679    }
1680    fn write_to(&self, buf: &mut impl ::buffa::bytes::BufMut) {
1681        #[allow(unused_imports)]
1682        use ::buffa::Enumeration as _;
1683        if let ::core::option::Option::Some(ref v) = self.kind {
1684            match v {
1685                policy_retain::Kind::KeepLatest(x) => {
1686                    ::buffa::encoding::Tag::new(
1687                            1u32,
1688                            ::buffa::encoding::WireType::LengthDelimited,
1689                        )
1690                        .encode(buf);
1691                    ::buffa::encoding::encode_varint(x.cached_size() as u64, buf);
1692                    x.write_to(buf);
1693                }
1694                policy_retain::Kind::GreaterThan(x) => {
1695                    ::buffa::encoding::Tag::new(
1696                            2u32,
1697                            ::buffa::encoding::WireType::LengthDelimited,
1698                        )
1699                        .encode(buf);
1700                    ::buffa::encoding::encode_varint(x.cached_size() as u64, buf);
1701                    x.write_to(buf);
1702                }
1703                policy_retain::Kind::GreaterThanOrEqual(x) => {
1704                    ::buffa::encoding::Tag::new(
1705                            3u32,
1706                            ::buffa::encoding::WireType::LengthDelimited,
1707                        )
1708                        .encode(buf);
1709                    ::buffa::encoding::encode_varint(x.cached_size() as u64, buf);
1710                    x.write_to(buf);
1711                }
1712                policy_retain::Kind::DropAll(x) => {
1713                    ::buffa::encoding::Tag::new(
1714                            4u32,
1715                            ::buffa::encoding::WireType::LengthDelimited,
1716                        )
1717                        .encode(buf);
1718                    ::buffa::encoding::encode_varint(x.cached_size() as u64, buf);
1719                    x.write_to(buf);
1720                }
1721            }
1722        }
1723        self.__buffa_unknown_fields.write_to(buf);
1724    }
1725    fn merge_field(
1726        &mut self,
1727        tag: ::buffa::encoding::Tag,
1728        buf: &mut impl ::buffa::bytes::Buf,
1729        depth: u32,
1730    ) -> ::core::result::Result<(), ::buffa::DecodeError> {
1731        #[allow(unused_imports)]
1732        use ::buffa::bytes::Buf as _;
1733        #[allow(unused_imports)]
1734        use ::buffa::Enumeration as _;
1735        match tag.field_number() {
1736            1u32 => {
1737                if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
1738                    return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
1739                        field_number: 1u32,
1740                        expected: 2u8,
1741                        actual: tag.wire_type() as u8,
1742                    });
1743                }
1744                if let ::core::option::Option::Some(
1745                    policy_retain::Kind::KeepLatest(ref mut existing),
1746                ) = self.kind
1747                {
1748                    ::buffa::Message::merge_length_delimited(
1749                        &mut **existing,
1750                        buf,
1751                        depth,
1752                    )?;
1753                } else {
1754                    let mut val = ::core::default::Default::default();
1755                    ::buffa::Message::merge_length_delimited(&mut val, buf, depth)?;
1756                    self.kind = ::core::option::Option::Some(
1757                        policy_retain::Kind::KeepLatest(
1758                            ::buffa::alloc::boxed::Box::new(val),
1759                        ),
1760                    );
1761                }
1762            }
1763            2u32 => {
1764                if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
1765                    return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
1766                        field_number: 2u32,
1767                        expected: 2u8,
1768                        actual: tag.wire_type() as u8,
1769                    });
1770                }
1771                if let ::core::option::Option::Some(
1772                    policy_retain::Kind::GreaterThan(ref mut existing),
1773                ) = self.kind
1774                {
1775                    ::buffa::Message::merge_length_delimited(
1776                        &mut **existing,
1777                        buf,
1778                        depth,
1779                    )?;
1780                } else {
1781                    let mut val = ::core::default::Default::default();
1782                    ::buffa::Message::merge_length_delimited(&mut val, buf, depth)?;
1783                    self.kind = ::core::option::Option::Some(
1784                        policy_retain::Kind::GreaterThan(
1785                            ::buffa::alloc::boxed::Box::new(val),
1786                        ),
1787                    );
1788                }
1789            }
1790            3u32 => {
1791                if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
1792                    return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
1793                        field_number: 3u32,
1794                        expected: 2u8,
1795                        actual: tag.wire_type() as u8,
1796                    });
1797                }
1798                if let ::core::option::Option::Some(
1799                    policy_retain::Kind::GreaterThanOrEqual(ref mut existing),
1800                ) = self.kind
1801                {
1802                    ::buffa::Message::merge_length_delimited(
1803                        &mut **existing,
1804                        buf,
1805                        depth,
1806                    )?;
1807                } else {
1808                    let mut val = ::core::default::Default::default();
1809                    ::buffa::Message::merge_length_delimited(&mut val, buf, depth)?;
1810                    self.kind = ::core::option::Option::Some(
1811                        policy_retain::Kind::GreaterThanOrEqual(
1812                            ::buffa::alloc::boxed::Box::new(val),
1813                        ),
1814                    );
1815                }
1816            }
1817            4u32 => {
1818                if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
1819                    return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
1820                        field_number: 4u32,
1821                        expected: 2u8,
1822                        actual: tag.wire_type() as u8,
1823                    });
1824                }
1825                if let ::core::option::Option::Some(
1826                    policy_retain::Kind::DropAll(ref mut existing),
1827                ) = self.kind
1828                {
1829                    ::buffa::Message::merge_length_delimited(
1830                        &mut **existing,
1831                        buf,
1832                        depth,
1833                    )?;
1834                } else {
1835                    let mut val = ::core::default::Default::default();
1836                    ::buffa::Message::merge_length_delimited(&mut val, buf, depth)?;
1837                    self.kind = ::core::option::Option::Some(
1838                        policy_retain::Kind::DropAll(
1839                            ::buffa::alloc::boxed::Box::new(val),
1840                        ),
1841                    );
1842                }
1843            }
1844            _ => {
1845                self.__buffa_unknown_fields
1846                    .push(::buffa::encoding::decode_unknown_field(tag, buf, depth)?);
1847            }
1848        }
1849        ::core::result::Result::Ok(())
1850    }
1851    fn cached_size(&self) -> u32 {
1852        self.__buffa_cached_size.get()
1853    }
1854    fn clear(&mut self) {
1855        self.kind = ::core::option::Option::None;
1856        self.__buffa_unknown_fields.clear();
1857        self.__buffa_cached_size.set(0);
1858    }
1859}
1860impl ::buffa::ExtensionSet for PolicyRetain {
1861    const PROTO_FQN: &'static str = "store.compact.v1.PolicyRetain";
1862    fn unknown_fields(&self) -> &::buffa::UnknownFields {
1863        &self.__buffa_unknown_fields
1864    }
1865    fn unknown_fields_mut(&mut self) -> &mut ::buffa::UnknownFields {
1866        &mut self.__buffa_unknown_fields
1867    }
1868}
1869impl<'de> serde::Deserialize<'de> for PolicyRetain {
1870    fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
1871        struct _V;
1872        impl<'de> serde::de::Visitor<'de> for _V {
1873            type Value = PolicyRetain;
1874            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
1875                f.write_str("struct PolicyRetain")
1876            }
1877            #[allow(clippy::field_reassign_with_default)]
1878            fn visit_map<A: serde::de::MapAccess<'de>>(
1879                self,
1880                mut map: A,
1881            ) -> Result<PolicyRetain, A::Error> {
1882                let mut __oneof_kind: Option<policy_retain::Kind> = None;
1883                while let Some(key) = map.next_key::<::buffa::alloc::string::String>()? {
1884                    match key.as_str() {
1885                        "keepLatest" | "keep_latest" => {
1886                            let v: Option<RetainKeepLatest> = map
1887                                .next_value_seed(
1888                                    ::buffa::json_helpers::NullableDeserializeSeed(
1889                                        ::buffa::json_helpers::DefaultDeserializeSeed::<
1890                                            RetainKeepLatest,
1891                                        >::new(),
1892                                    ),
1893                                )?;
1894                            if let Some(v) = v {
1895                                if __oneof_kind.is_some() {
1896                                    return Err(
1897                                        serde::de::Error::custom(
1898                                            "multiple oneof fields set for 'kind'",
1899                                        ),
1900                                    );
1901                                }
1902                                __oneof_kind = Some(
1903                                    policy_retain::Kind::KeepLatest(
1904                                        ::buffa::alloc::boxed::Box::new(v),
1905                                    ),
1906                                );
1907                            }
1908                        }
1909                        "greaterThan" | "greater_than" => {
1910                            let v: Option<RetainGreaterThan> = map
1911                                .next_value_seed(
1912                                    ::buffa::json_helpers::NullableDeserializeSeed(
1913                                        ::buffa::json_helpers::DefaultDeserializeSeed::<
1914                                            RetainGreaterThan,
1915                                        >::new(),
1916                                    ),
1917                                )?;
1918                            if let Some(v) = v {
1919                                if __oneof_kind.is_some() {
1920                                    return Err(
1921                                        serde::de::Error::custom(
1922                                            "multiple oneof fields set for 'kind'",
1923                                        ),
1924                                    );
1925                                }
1926                                __oneof_kind = Some(
1927                                    policy_retain::Kind::GreaterThan(
1928                                        ::buffa::alloc::boxed::Box::new(v),
1929                                    ),
1930                                );
1931                            }
1932                        }
1933                        "greaterThanOrEqual" | "greater_than_or_equal" => {
1934                            let v: Option<RetainGreaterThanOrEqual> = map
1935                                .next_value_seed(
1936                                    ::buffa::json_helpers::NullableDeserializeSeed(
1937                                        ::buffa::json_helpers::DefaultDeserializeSeed::<
1938                                            RetainGreaterThanOrEqual,
1939                                        >::new(),
1940                                    ),
1941                                )?;
1942                            if let Some(v) = v {
1943                                if __oneof_kind.is_some() {
1944                                    return Err(
1945                                        serde::de::Error::custom(
1946                                            "multiple oneof fields set for 'kind'",
1947                                        ),
1948                                    );
1949                                }
1950                                __oneof_kind = Some(
1951                                    policy_retain::Kind::GreaterThanOrEqual(
1952                                        ::buffa::alloc::boxed::Box::new(v),
1953                                    ),
1954                                );
1955                            }
1956                        }
1957                        "dropAll" | "drop_all" => {
1958                            let v: Option<RetainDropAll> = map
1959                                .next_value_seed(
1960                                    ::buffa::json_helpers::NullableDeserializeSeed(
1961                                        ::buffa::json_helpers::DefaultDeserializeSeed::<
1962                                            RetainDropAll,
1963                                        >::new(),
1964                                    ),
1965                                )?;
1966                            if let Some(v) = v {
1967                                if __oneof_kind.is_some() {
1968                                    return Err(
1969                                        serde::de::Error::custom(
1970                                            "multiple oneof fields set for 'kind'",
1971                                        ),
1972                                    );
1973                                }
1974                                __oneof_kind = Some(
1975                                    policy_retain::Kind::DropAll(
1976                                        ::buffa::alloc::boxed::Box::new(v),
1977                                    ),
1978                                );
1979                            }
1980                        }
1981                        _ => {
1982                            map.next_value::<serde::de::IgnoredAny>()?;
1983                        }
1984                    }
1985                }
1986                let mut __r = <PolicyRetain as ::core::default::Default>::default();
1987                __r.kind = __oneof_kind;
1988                Ok(__r)
1989            }
1990        }
1991        d.deserialize_map(_V)
1992    }
1993}
1994impl ::buffa::json_helpers::ProtoElemJson for PolicyRetain {
1995    fn serialize_proto_json<S: ::serde::Serializer>(
1996        v: &Self,
1997        s: S,
1998    ) -> ::core::result::Result<S::Ok, S::Error> {
1999        ::serde::Serialize::serialize(v, s)
2000    }
2001    fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>(
2002        d: D,
2003    ) -> ::core::result::Result<Self, D::Error> {
2004        <Self as ::serde::Deserialize>::deserialize(d)
2005    }
2006}
2007#[doc(hidden)]
2008pub const __POLICY_RETAIN_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry {
2009    type_url: "type.googleapis.com/store.compact.v1.PolicyRetain",
2010    to_json: ::buffa::type_registry::any_to_json::<PolicyRetain>,
2011    from_json: ::buffa::type_registry::any_from_json::<PolicyRetain>,
2012    is_wkt: false,
2013};
2014/// Selects which entries survive pruning within each group.
2015#[derive(Clone, Debug, Default)]
2016pub struct PolicyRetainView<'a> {
2017    pub kind: ::core::option::Option<policy_retain::KindView<'a>>,
2018    pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
2019}
2020impl<'a> PolicyRetainView<'a> {
2021    /// Decode from `buf`, enforcing a recursion depth limit for nested messages.
2022    ///
2023    /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`]
2024    /// and by generated sub-message decode arms with `depth - 1`.
2025    ///
2026    /// **Not part of the public API.** Named with a leading underscore to
2027    /// signal that it is for generated-code use only.
2028    #[doc(hidden)]
2029    pub fn _decode_depth(
2030        buf: &'a [u8],
2031        depth: u32,
2032    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
2033        let mut view = Self::default();
2034        view._merge_into_view(buf, depth)?;
2035        ::core::result::Result::Ok(view)
2036    }
2037    /// Merge fields from `buf` into this view (proto merge semantics).
2038    ///
2039    /// Repeated fields append; singular fields last-wins; singular
2040    /// MESSAGE fields merge recursively. Used by sub-message decode
2041    /// arms when the same field appears multiple times on the wire.
2042    ///
2043    /// **Not part of the public API.**
2044    #[doc(hidden)]
2045    pub fn _merge_into_view(
2046        &mut self,
2047        buf: &'a [u8],
2048        depth: u32,
2049    ) -> ::core::result::Result<(), ::buffa::DecodeError> {
2050        let _ = depth;
2051        #[allow(unused_variables)]
2052        let view = self;
2053        let mut cur: &'a [u8] = buf;
2054        while !cur.is_empty() {
2055            let before_tag = cur;
2056            let tag = ::buffa::encoding::Tag::decode(&mut cur)?;
2057            match tag.field_number() {
2058                1u32 => {
2059                    if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
2060                        return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
2061                            field_number: 1u32,
2062                            expected: 2u8,
2063                            actual: tag.wire_type() as u8,
2064                        });
2065                    }
2066                    if depth == 0 {
2067                        return Err(::buffa::DecodeError::RecursionLimitExceeded);
2068                    }
2069                    let sub = ::buffa::types::borrow_bytes(&mut cur)?;
2070                    if let Some(policy_retain::KindView::KeepLatest(ref mut existing)) = view
2071                        .kind
2072                    {
2073                        existing._merge_into_view(sub, depth - 1)?;
2074                    } else {
2075                        view.kind = Some(
2076                            policy_retain::KindView::KeepLatest(
2077                                ::buffa::alloc::boxed::Box::new(
2078                                    RetainKeepLatestView::_decode_depth(sub, depth - 1)?,
2079                                ),
2080                            ),
2081                        );
2082                    }
2083                }
2084                2u32 => {
2085                    if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
2086                        return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
2087                            field_number: 2u32,
2088                            expected: 2u8,
2089                            actual: tag.wire_type() as u8,
2090                        });
2091                    }
2092                    if depth == 0 {
2093                        return Err(::buffa::DecodeError::RecursionLimitExceeded);
2094                    }
2095                    let sub = ::buffa::types::borrow_bytes(&mut cur)?;
2096                    if let Some(
2097                        policy_retain::KindView::GreaterThan(ref mut existing),
2098                    ) = view.kind
2099                    {
2100                        existing._merge_into_view(sub, depth - 1)?;
2101                    } else {
2102                        view.kind = Some(
2103                            policy_retain::KindView::GreaterThan(
2104                                ::buffa::alloc::boxed::Box::new(
2105                                    RetainGreaterThanView::_decode_depth(sub, depth - 1)?,
2106                                ),
2107                            ),
2108                        );
2109                    }
2110                }
2111                3u32 => {
2112                    if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
2113                        return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
2114                            field_number: 3u32,
2115                            expected: 2u8,
2116                            actual: tag.wire_type() as u8,
2117                        });
2118                    }
2119                    if depth == 0 {
2120                        return Err(::buffa::DecodeError::RecursionLimitExceeded);
2121                    }
2122                    let sub = ::buffa::types::borrow_bytes(&mut cur)?;
2123                    if let Some(
2124                        policy_retain::KindView::GreaterThanOrEqual(ref mut existing),
2125                    ) = view.kind
2126                    {
2127                        existing._merge_into_view(sub, depth - 1)?;
2128                    } else {
2129                        view.kind = Some(
2130                            policy_retain::KindView::GreaterThanOrEqual(
2131                                ::buffa::alloc::boxed::Box::new(
2132                                    RetainGreaterThanOrEqualView::_decode_depth(sub, depth - 1)?,
2133                                ),
2134                            ),
2135                        );
2136                    }
2137                }
2138                4u32 => {
2139                    if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
2140                        return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
2141                            field_number: 4u32,
2142                            expected: 2u8,
2143                            actual: tag.wire_type() as u8,
2144                        });
2145                    }
2146                    if depth == 0 {
2147                        return Err(::buffa::DecodeError::RecursionLimitExceeded);
2148                    }
2149                    let sub = ::buffa::types::borrow_bytes(&mut cur)?;
2150                    if let Some(policy_retain::KindView::DropAll(ref mut existing)) = view
2151                        .kind
2152                    {
2153                        existing._merge_into_view(sub, depth - 1)?;
2154                    } else {
2155                        view.kind = Some(
2156                            policy_retain::KindView::DropAll(
2157                                ::buffa::alloc::boxed::Box::new(
2158                                    RetainDropAllView::_decode_depth(sub, depth - 1)?,
2159                                ),
2160                            ),
2161                        );
2162                    }
2163                }
2164                _ => {
2165                    ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?;
2166                    let span_len = before_tag.len() - cur.len();
2167                    view.__buffa_unknown_fields.push_raw(&before_tag[..span_len]);
2168                }
2169            }
2170        }
2171        ::core::result::Result::Ok(())
2172    }
2173}
2174impl<'a> ::buffa::MessageView<'a> for PolicyRetainView<'a> {
2175    type Owned = PolicyRetain;
2176    fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
2177        Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT)
2178    }
2179    fn decode_view_with_limit(
2180        buf: &'a [u8],
2181        depth: u32,
2182    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
2183        Self::_decode_depth(buf, depth)
2184    }
2185    /// Convert this view to the owned message type.
2186    #[allow(clippy::redundant_closure, clippy::useless_conversion)]
2187    fn to_owned_message(&self) -> PolicyRetain {
2188        #[allow(unused_imports)]
2189        use ::buffa::alloc::string::ToString as _;
2190        PolicyRetain {
2191            kind: self
2192                .kind
2193                .as_ref()
2194                .map(|v| match v {
2195                    policy_retain::KindView::KeepLatest(v) => {
2196                        policy_retain::Kind::KeepLatest(
2197                            ::buffa::alloc::boxed::Box::new(v.to_owned_message()),
2198                        )
2199                    }
2200                    policy_retain::KindView::GreaterThan(v) => {
2201                        policy_retain::Kind::GreaterThan(
2202                            ::buffa::alloc::boxed::Box::new(v.to_owned_message()),
2203                        )
2204                    }
2205                    policy_retain::KindView::GreaterThanOrEqual(v) => {
2206                        policy_retain::Kind::GreaterThanOrEqual(
2207                            ::buffa::alloc::boxed::Box::new(v.to_owned_message()),
2208                        )
2209                    }
2210                    policy_retain::KindView::DropAll(v) => {
2211                        policy_retain::Kind::DropAll(
2212                            ::buffa::alloc::boxed::Box::new(v.to_owned_message()),
2213                        )
2214                    }
2215                }),
2216            __buffa_unknown_fields: self
2217                .__buffa_unknown_fields
2218                .to_owned()
2219                .unwrap_or_default()
2220                .into(),
2221            ..::core::default::Default::default()
2222        }
2223    }
2224}
2225unsafe impl ::buffa::DefaultViewInstance for PolicyRetainView<'static> {
2226    fn default_view_instance() -> &'static Self {
2227        static VALUE: ::buffa::__private::OnceBox<PolicyRetainView<'static>> = ::buffa::__private::OnceBox::new();
2228        VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default()))
2229    }
2230}
2231unsafe impl<'a> ::buffa::HasDefaultViewInstance for PolicyRetainView<'a> {
2232    type Static = PolicyRetainView<'static>;
2233}
2234pub mod policy_retain {
2235    #[allow(unused_imports)]
2236    use super::*;
2237    #[derive(Clone, PartialEq, Debug)]
2238    pub enum Kind {
2239        KeepLatest(::buffa::alloc::boxed::Box<super::RetainKeepLatest>),
2240        GreaterThan(::buffa::alloc::boxed::Box<super::RetainGreaterThan>),
2241        GreaterThanOrEqual(::buffa::alloc::boxed::Box<super::RetainGreaterThanOrEqual>),
2242        DropAll(::buffa::alloc::boxed::Box<super::RetainDropAll>),
2243    }
2244    impl ::buffa::Oneof for Kind {}
2245    impl From<super::RetainKeepLatest> for Kind {
2246        fn from(v: super::RetainKeepLatest) -> Self {
2247            Self::KeepLatest(::buffa::alloc::boxed::Box::new(v))
2248        }
2249    }
2250    impl From<super::RetainKeepLatest> for ::core::option::Option<Kind> {
2251        fn from(v: super::RetainKeepLatest) -> Self {
2252            Self::Some(Kind::from(v))
2253        }
2254    }
2255    impl From<super::RetainGreaterThan> for Kind {
2256        fn from(v: super::RetainGreaterThan) -> Self {
2257            Self::GreaterThan(::buffa::alloc::boxed::Box::new(v))
2258        }
2259    }
2260    impl From<super::RetainGreaterThan> for ::core::option::Option<Kind> {
2261        fn from(v: super::RetainGreaterThan) -> Self {
2262            Self::Some(Kind::from(v))
2263        }
2264    }
2265    impl From<super::RetainGreaterThanOrEqual> for Kind {
2266        fn from(v: super::RetainGreaterThanOrEqual) -> Self {
2267            Self::GreaterThanOrEqual(::buffa::alloc::boxed::Box::new(v))
2268        }
2269    }
2270    impl From<super::RetainGreaterThanOrEqual> for ::core::option::Option<Kind> {
2271        fn from(v: super::RetainGreaterThanOrEqual) -> Self {
2272            Self::Some(Kind::from(v))
2273        }
2274    }
2275    impl From<super::RetainDropAll> for Kind {
2276        fn from(v: super::RetainDropAll) -> Self {
2277            Self::DropAll(::buffa::alloc::boxed::Box::new(v))
2278        }
2279    }
2280    impl From<super::RetainDropAll> for ::core::option::Option<Kind> {
2281        fn from(v: super::RetainDropAll) -> Self {
2282            Self::Some(Kind::from(v))
2283        }
2284    }
2285    impl serde::Serialize for Kind {
2286        fn serialize<S: serde::Serializer>(
2287            &self,
2288            s: S,
2289        ) -> ::core::result::Result<S::Ok, S::Error> {
2290            use serde::ser::SerializeMap;
2291            let mut map = s.serialize_map(Some(1))?;
2292            match self {
2293                Kind::KeepLatest(v) => {
2294                    map.serialize_entry("keepLatest", v)?;
2295                }
2296                Kind::GreaterThan(v) => {
2297                    map.serialize_entry("greaterThan", v)?;
2298                }
2299                Kind::GreaterThanOrEqual(v) => {
2300                    map.serialize_entry("greaterThanOrEqual", v)?;
2301                }
2302                Kind::DropAll(v) => {
2303                    map.serialize_entry("dropAll", v)?;
2304                }
2305            }
2306            map.end()
2307        }
2308    }
2309    #[derive(Clone, Debug)]
2310    pub enum KindView<'a> {
2311        KeepLatest(::buffa::alloc::boxed::Box<super::RetainKeepLatestView<'a>>),
2312        GreaterThan(::buffa::alloc::boxed::Box<super::RetainGreaterThanView<'a>>),
2313        GreaterThanOrEqual(
2314            ::buffa::alloc::boxed::Box<super::RetainGreaterThanOrEqualView<'a>>,
2315        ),
2316        DropAll(::buffa::alloc::boxed::Box<super::RetainDropAllView<'a>>),
2317    }
2318}
2319/// User-key-space scope: scan a KeyCodec family by `match_key`, partition
2320/// matched keys into `group_by` groups, order within each group by
2321/// `order_by`, then apply `retain` to decide which keys to delete.
2322#[derive(Clone, PartialEq, Default)]
2323#[derive(::serde::Serialize, ::serde::Deserialize)]
2324#[serde(default)]
2325pub struct KeysScope {
2326    /// Field 1: `match_key`
2327    #[serde(
2328        rename = "matchKey",
2329        alias = "match_key",
2330        skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field"
2331    )]
2332    pub match_key: ::buffa::MessageField<super::super::common::v1::MatchKey>,
2333    /// Field 2: `group_by`
2334    #[serde(
2335        rename = "groupBy",
2336        alias = "group_by",
2337        skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field"
2338    )]
2339    pub group_by: ::buffa::MessageField<PolicyGroupBy>,
2340    /// Field 3: `order_by`
2341    #[serde(
2342        rename = "orderBy",
2343        alias = "order_by",
2344        skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field"
2345    )]
2346    pub order_by: ::buffa::MessageField<PolicyOrderBy>,
2347    #[serde(skip)]
2348    #[doc(hidden)]
2349    pub __buffa_unknown_fields: ::buffa::UnknownFields,
2350    #[doc(hidden)]
2351    #[serde(skip)]
2352    pub __buffa_cached_size: ::buffa::__private::CachedSize,
2353}
2354impl ::core::fmt::Debug for KeysScope {
2355    fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
2356        f.debug_struct("KeysScope")
2357            .field("match_key", &self.match_key)
2358            .field("group_by", &self.group_by)
2359            .field("order_by", &self.order_by)
2360            .finish()
2361    }
2362}
2363impl KeysScope {
2364    /// Protobuf type URL for this message, for use with `Any::pack` and
2365    /// `Any::unpack_if`.
2366    ///
2367    /// Format: `type.googleapis.com/<fully.qualified.TypeName>`
2368    pub const TYPE_URL: &'static str = "type.googleapis.com/store.compact.v1.KeysScope";
2369}
2370unsafe impl ::buffa::DefaultInstance for KeysScope {
2371    fn default_instance() -> &'static Self {
2372        static VALUE: ::buffa::__private::OnceBox<KeysScope> = ::buffa::__private::OnceBox::new();
2373        VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default()))
2374    }
2375}
2376impl ::buffa::Message for KeysScope {
2377    /// Returns the total encoded size in bytes.
2378    ///
2379    /// The result is a `u32`; the protobuf specification requires all
2380    /// messages to fit within 2 GiB (2,147,483,647 bytes), so a
2381    /// compliant message will never overflow this type.
2382    fn compute_size(&self) -> u32 {
2383        #[allow(unused_imports)]
2384        use ::buffa::Enumeration as _;
2385        let mut size = 0u32;
2386        if self.match_key.is_set() {
2387            let inner_size = self.match_key.compute_size();
2388            size
2389                += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
2390                    + inner_size;
2391        }
2392        if self.group_by.is_set() {
2393            let inner_size = self.group_by.compute_size();
2394            size
2395                += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
2396                    + inner_size;
2397        }
2398        if self.order_by.is_set() {
2399            let inner_size = self.order_by.compute_size();
2400            size
2401                += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
2402                    + inner_size;
2403        }
2404        size += self.__buffa_unknown_fields.encoded_len() as u32;
2405        self.__buffa_cached_size.set(size);
2406        size
2407    }
2408    fn write_to(&self, buf: &mut impl ::buffa::bytes::BufMut) {
2409        #[allow(unused_imports)]
2410        use ::buffa::Enumeration as _;
2411        if self.match_key.is_set() {
2412            ::buffa::encoding::Tag::new(
2413                    1u32,
2414                    ::buffa::encoding::WireType::LengthDelimited,
2415                )
2416                .encode(buf);
2417            ::buffa::encoding::encode_varint(self.match_key.cached_size() as u64, buf);
2418            self.match_key.write_to(buf);
2419        }
2420        if self.group_by.is_set() {
2421            ::buffa::encoding::Tag::new(
2422                    2u32,
2423                    ::buffa::encoding::WireType::LengthDelimited,
2424                )
2425                .encode(buf);
2426            ::buffa::encoding::encode_varint(self.group_by.cached_size() as u64, buf);
2427            self.group_by.write_to(buf);
2428        }
2429        if self.order_by.is_set() {
2430            ::buffa::encoding::Tag::new(
2431                    3u32,
2432                    ::buffa::encoding::WireType::LengthDelimited,
2433                )
2434                .encode(buf);
2435            ::buffa::encoding::encode_varint(self.order_by.cached_size() as u64, buf);
2436            self.order_by.write_to(buf);
2437        }
2438        self.__buffa_unknown_fields.write_to(buf);
2439    }
2440    fn merge_field(
2441        &mut self,
2442        tag: ::buffa::encoding::Tag,
2443        buf: &mut impl ::buffa::bytes::Buf,
2444        depth: u32,
2445    ) -> ::core::result::Result<(), ::buffa::DecodeError> {
2446        #[allow(unused_imports)]
2447        use ::buffa::bytes::Buf as _;
2448        #[allow(unused_imports)]
2449        use ::buffa::Enumeration as _;
2450        match tag.field_number() {
2451            1u32 => {
2452                if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
2453                    return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
2454                        field_number: 1u32,
2455                        expected: 2u8,
2456                        actual: tag.wire_type() as u8,
2457                    });
2458                }
2459                ::buffa::Message::merge_length_delimited(
2460                    self.match_key.get_or_insert_default(),
2461                    buf,
2462                    depth,
2463                )?;
2464            }
2465            2u32 => {
2466                if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
2467                    return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
2468                        field_number: 2u32,
2469                        expected: 2u8,
2470                        actual: tag.wire_type() as u8,
2471                    });
2472                }
2473                ::buffa::Message::merge_length_delimited(
2474                    self.group_by.get_or_insert_default(),
2475                    buf,
2476                    depth,
2477                )?;
2478            }
2479            3u32 => {
2480                if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
2481                    return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
2482                        field_number: 3u32,
2483                        expected: 2u8,
2484                        actual: tag.wire_type() as u8,
2485                    });
2486                }
2487                ::buffa::Message::merge_length_delimited(
2488                    self.order_by.get_or_insert_default(),
2489                    buf,
2490                    depth,
2491                )?;
2492            }
2493            _ => {
2494                self.__buffa_unknown_fields
2495                    .push(::buffa::encoding::decode_unknown_field(tag, buf, depth)?);
2496            }
2497        }
2498        ::core::result::Result::Ok(())
2499    }
2500    fn cached_size(&self) -> u32 {
2501        self.__buffa_cached_size.get()
2502    }
2503    fn clear(&mut self) {
2504        self.match_key = ::buffa::MessageField::none();
2505        self.group_by = ::buffa::MessageField::none();
2506        self.order_by = ::buffa::MessageField::none();
2507        self.__buffa_unknown_fields.clear();
2508        self.__buffa_cached_size.set(0);
2509    }
2510}
2511impl ::buffa::ExtensionSet for KeysScope {
2512    const PROTO_FQN: &'static str = "store.compact.v1.KeysScope";
2513    fn unknown_fields(&self) -> &::buffa::UnknownFields {
2514        &self.__buffa_unknown_fields
2515    }
2516    fn unknown_fields_mut(&mut self) -> &mut ::buffa::UnknownFields {
2517        &mut self.__buffa_unknown_fields
2518    }
2519}
2520impl ::buffa::json_helpers::ProtoElemJson for KeysScope {
2521    fn serialize_proto_json<S: ::serde::Serializer>(
2522        v: &Self,
2523        s: S,
2524    ) -> ::core::result::Result<S::Ok, S::Error> {
2525        ::serde::Serialize::serialize(v, s)
2526    }
2527    fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>(
2528        d: D,
2529    ) -> ::core::result::Result<Self, D::Error> {
2530        <Self as ::serde::Deserialize>::deserialize(d)
2531    }
2532}
2533#[doc(hidden)]
2534pub const __KEYS_SCOPE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry {
2535    type_url: "type.googleapis.com/store.compact.v1.KeysScope",
2536    to_json: ::buffa::type_registry::any_to_json::<KeysScope>,
2537    from_json: ::buffa::type_registry::any_from_json::<KeysScope>,
2538    is_wkt: false,
2539};
2540/// User-key-space scope: scan a KeyCodec family by `match_key`, partition
2541/// matched keys into `group_by` groups, order within each group by
2542/// `order_by`, then apply `retain` to decide which keys to delete.
2543#[derive(Clone, Debug, Default)]
2544pub struct KeysScopeView<'a> {
2545    /// Field 1: `match_key`
2546    pub match_key: ::buffa::MessageFieldView<super::super::common::v1::MatchKeyView<'a>>,
2547    /// Field 2: `group_by`
2548    pub group_by: ::buffa::MessageFieldView<PolicyGroupByView<'a>>,
2549    /// Field 3: `order_by`
2550    pub order_by: ::buffa::MessageFieldView<PolicyOrderByView<'a>>,
2551    pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
2552}
2553impl<'a> KeysScopeView<'a> {
2554    /// Decode from `buf`, enforcing a recursion depth limit for nested messages.
2555    ///
2556    /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`]
2557    /// and by generated sub-message decode arms with `depth - 1`.
2558    ///
2559    /// **Not part of the public API.** Named with a leading underscore to
2560    /// signal that it is for generated-code use only.
2561    #[doc(hidden)]
2562    pub fn _decode_depth(
2563        buf: &'a [u8],
2564        depth: u32,
2565    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
2566        let mut view = Self::default();
2567        view._merge_into_view(buf, depth)?;
2568        ::core::result::Result::Ok(view)
2569    }
2570    /// Merge fields from `buf` into this view (proto merge semantics).
2571    ///
2572    /// Repeated fields append; singular fields last-wins; singular
2573    /// MESSAGE fields merge recursively. Used by sub-message decode
2574    /// arms when the same field appears multiple times on the wire.
2575    ///
2576    /// **Not part of the public API.**
2577    #[doc(hidden)]
2578    pub fn _merge_into_view(
2579        &mut self,
2580        buf: &'a [u8],
2581        depth: u32,
2582    ) -> ::core::result::Result<(), ::buffa::DecodeError> {
2583        let _ = depth;
2584        #[allow(unused_variables)]
2585        let view = self;
2586        let mut cur: &'a [u8] = buf;
2587        while !cur.is_empty() {
2588            let before_tag = cur;
2589            let tag = ::buffa::encoding::Tag::decode(&mut cur)?;
2590            match tag.field_number() {
2591                1u32 => {
2592                    if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
2593                        return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
2594                            field_number: 1u32,
2595                            expected: 2u8,
2596                            actual: tag.wire_type() as u8,
2597                        });
2598                    }
2599                    if depth == 0 {
2600                        return Err(::buffa::DecodeError::RecursionLimitExceeded);
2601                    }
2602                    let sub = ::buffa::types::borrow_bytes(&mut cur)?;
2603                    match view.match_key.as_mut() {
2604                        Some(existing) => existing._merge_into_view(sub, depth - 1)?,
2605                        None => {
2606                            view.match_key = ::buffa::MessageFieldView::set(
2607                                super::super::common::v1::MatchKeyView::_decode_depth(
2608                                    sub,
2609                                    depth - 1,
2610                                )?,
2611                            );
2612                        }
2613                    }
2614                }
2615                2u32 => {
2616                    if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
2617                        return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
2618                            field_number: 2u32,
2619                            expected: 2u8,
2620                            actual: tag.wire_type() as u8,
2621                        });
2622                    }
2623                    if depth == 0 {
2624                        return Err(::buffa::DecodeError::RecursionLimitExceeded);
2625                    }
2626                    let sub = ::buffa::types::borrow_bytes(&mut cur)?;
2627                    match view.group_by.as_mut() {
2628                        Some(existing) => existing._merge_into_view(sub, depth - 1)?,
2629                        None => {
2630                            view.group_by = ::buffa::MessageFieldView::set(
2631                                PolicyGroupByView::_decode_depth(sub, depth - 1)?,
2632                            );
2633                        }
2634                    }
2635                }
2636                3u32 => {
2637                    if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
2638                        return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
2639                            field_number: 3u32,
2640                            expected: 2u8,
2641                            actual: tag.wire_type() as u8,
2642                        });
2643                    }
2644                    if depth == 0 {
2645                        return Err(::buffa::DecodeError::RecursionLimitExceeded);
2646                    }
2647                    let sub = ::buffa::types::borrow_bytes(&mut cur)?;
2648                    match view.order_by.as_mut() {
2649                        Some(existing) => existing._merge_into_view(sub, depth - 1)?,
2650                        None => {
2651                            view.order_by = ::buffa::MessageFieldView::set(
2652                                PolicyOrderByView::_decode_depth(sub, depth - 1)?,
2653                            );
2654                        }
2655                    }
2656                }
2657                _ => {
2658                    ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?;
2659                    let span_len = before_tag.len() - cur.len();
2660                    view.__buffa_unknown_fields.push_raw(&before_tag[..span_len]);
2661                }
2662            }
2663        }
2664        ::core::result::Result::Ok(())
2665    }
2666}
2667impl<'a> ::buffa::MessageView<'a> for KeysScopeView<'a> {
2668    type Owned = KeysScope;
2669    fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
2670        Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT)
2671    }
2672    fn decode_view_with_limit(
2673        buf: &'a [u8],
2674        depth: u32,
2675    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
2676        Self::_decode_depth(buf, depth)
2677    }
2678    /// Convert this view to the owned message type.
2679    #[allow(clippy::redundant_closure, clippy::useless_conversion)]
2680    fn to_owned_message(&self) -> KeysScope {
2681        #[allow(unused_imports)]
2682        use ::buffa::alloc::string::ToString as _;
2683        KeysScope {
2684            match_key: match self.match_key.as_option() {
2685                Some(v) => {
2686                    ::buffa::MessageField::<
2687                        super::super::common::v1::MatchKey,
2688                    >::some(v.to_owned_message())
2689                }
2690                None => ::buffa::MessageField::none(),
2691            },
2692            group_by: match self.group_by.as_option() {
2693                Some(v) => {
2694                    ::buffa::MessageField::<PolicyGroupBy>::some(v.to_owned_message())
2695                }
2696                None => ::buffa::MessageField::none(),
2697            },
2698            order_by: match self.order_by.as_option() {
2699                Some(v) => {
2700                    ::buffa::MessageField::<PolicyOrderBy>::some(v.to_owned_message())
2701                }
2702                None => ::buffa::MessageField::none(),
2703            },
2704            __buffa_unknown_fields: self
2705                .__buffa_unknown_fields
2706                .to_owned()
2707                .unwrap_or_default()
2708                .into(),
2709            ..::core::default::Default::default()
2710        }
2711    }
2712}
2713unsafe impl ::buffa::DefaultViewInstance for KeysScopeView<'static> {
2714    fn default_view_instance() -> &'static Self {
2715        static VALUE: ::buffa::__private::OnceBox<KeysScopeView<'static>> = ::buffa::__private::OnceBox::new();
2716        VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default()))
2717    }
2718}
2719unsafe impl<'a> ::buffa::HasDefaultViewInstance for KeysScopeView<'a> {
2720    type Static = KeysScopeView<'static>;
2721}
2722/// Sequence-number scope: prune the per-batch sequence log served by the
2723/// store's `Stream` service. `match_key` / `group_by` / `order_by` are not
2724/// meaningful here — the log has a single implicit ordering by sequence
2725/// number. The `retain` rule on the parent `Policy` is interpreted directly
2726/// over sequence numbers:
2727///
2728///   - `keep_latest { count: N }`        -\> keep the last N batches
2729///   - `greater_than { threshold: T }`   -\> keep sequence numbers \> T
2730///   - `greater_than_or_equal { .. T }`  -\> keep sequence numbers \>= T
2731///   - `drop_all`                        -\> clear the batch log entirely
2732#[derive(Clone, PartialEq, Default)]
2733#[derive(::serde::Serialize, ::serde::Deserialize)]
2734#[serde(default)]
2735pub struct SequenceScope {
2736    #[serde(skip)]
2737    #[doc(hidden)]
2738    pub __buffa_unknown_fields: ::buffa::UnknownFields,
2739    #[doc(hidden)]
2740    #[serde(skip)]
2741    pub __buffa_cached_size: ::buffa::__private::CachedSize,
2742}
2743impl ::core::fmt::Debug for SequenceScope {
2744    fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
2745        f.debug_struct("SequenceScope").finish()
2746    }
2747}
2748impl SequenceScope {
2749    /// Protobuf type URL for this message, for use with `Any::pack` and
2750    /// `Any::unpack_if`.
2751    ///
2752    /// Format: `type.googleapis.com/<fully.qualified.TypeName>`
2753    pub const TYPE_URL: &'static str = "type.googleapis.com/store.compact.v1.SequenceScope";
2754}
2755unsafe impl ::buffa::DefaultInstance for SequenceScope {
2756    fn default_instance() -> &'static Self {
2757        static VALUE: ::buffa::__private::OnceBox<SequenceScope> = ::buffa::__private::OnceBox::new();
2758        VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default()))
2759    }
2760}
2761impl ::buffa::Message for SequenceScope {
2762    /// Returns the total encoded size in bytes.
2763    ///
2764    /// The result is a `u32`; the protobuf specification requires all
2765    /// messages to fit within 2 GiB (2,147,483,647 bytes), so a
2766    /// compliant message will never overflow this type.
2767    fn compute_size(&self) -> u32 {
2768        #[allow(unused_imports)]
2769        use ::buffa::Enumeration as _;
2770        let mut size = 0u32;
2771        size += self.__buffa_unknown_fields.encoded_len() as u32;
2772        self.__buffa_cached_size.set(size);
2773        size
2774    }
2775    fn write_to(&self, buf: &mut impl ::buffa::bytes::BufMut) {
2776        #[allow(unused_imports)]
2777        use ::buffa::Enumeration as _;
2778        self.__buffa_unknown_fields.write_to(buf);
2779    }
2780    fn merge_field(
2781        &mut self,
2782        tag: ::buffa::encoding::Tag,
2783        buf: &mut impl ::buffa::bytes::Buf,
2784        depth: u32,
2785    ) -> ::core::result::Result<(), ::buffa::DecodeError> {
2786        #[allow(unused_imports)]
2787        use ::buffa::bytes::Buf as _;
2788        #[allow(unused_imports)]
2789        use ::buffa::Enumeration as _;
2790        match tag.field_number() {
2791            _ => {
2792                self.__buffa_unknown_fields
2793                    .push(::buffa::encoding::decode_unknown_field(tag, buf, depth)?);
2794            }
2795        }
2796        ::core::result::Result::Ok(())
2797    }
2798    fn cached_size(&self) -> u32 {
2799        self.__buffa_cached_size.get()
2800    }
2801    fn clear(&mut self) {
2802        self.__buffa_unknown_fields.clear();
2803        self.__buffa_cached_size.set(0);
2804    }
2805}
2806impl ::buffa::ExtensionSet for SequenceScope {
2807    const PROTO_FQN: &'static str = "store.compact.v1.SequenceScope";
2808    fn unknown_fields(&self) -> &::buffa::UnknownFields {
2809        &self.__buffa_unknown_fields
2810    }
2811    fn unknown_fields_mut(&mut self) -> &mut ::buffa::UnknownFields {
2812        &mut self.__buffa_unknown_fields
2813    }
2814}
2815impl ::buffa::json_helpers::ProtoElemJson for SequenceScope {
2816    fn serialize_proto_json<S: ::serde::Serializer>(
2817        v: &Self,
2818        s: S,
2819    ) -> ::core::result::Result<S::Ok, S::Error> {
2820        ::serde::Serialize::serialize(v, s)
2821    }
2822    fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>(
2823        d: D,
2824    ) -> ::core::result::Result<Self, D::Error> {
2825        <Self as ::serde::Deserialize>::deserialize(d)
2826    }
2827}
2828#[doc(hidden)]
2829pub const __SEQUENCE_SCOPE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry {
2830    type_url: "type.googleapis.com/store.compact.v1.SequenceScope",
2831    to_json: ::buffa::type_registry::any_to_json::<SequenceScope>,
2832    from_json: ::buffa::type_registry::any_from_json::<SequenceScope>,
2833    is_wkt: false,
2834};
2835/// Sequence-number scope: prune the per-batch sequence log served by the
2836/// store's `Stream` service. `match_key` / `group_by` / `order_by` are not
2837/// meaningful here — the log has a single implicit ordering by sequence
2838/// number. The `retain` rule on the parent `Policy` is interpreted directly
2839/// over sequence numbers:
2840///
2841///   - `keep_latest { count: N }`        -\> keep the last N batches
2842///   - `greater_than { threshold: T }`   -\> keep sequence numbers \> T
2843///   - `greater_than_or_equal { .. T }`  -\> keep sequence numbers \>= T
2844///   - `drop_all`                        -\> clear the batch log entirely
2845#[derive(Clone, Debug, Default)]
2846pub struct SequenceScopeView<'a> {
2847    pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
2848}
2849impl<'a> SequenceScopeView<'a> {
2850    /// Decode from `buf`, enforcing a recursion depth limit for nested messages.
2851    ///
2852    /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`]
2853    /// and by generated sub-message decode arms with `depth - 1`.
2854    ///
2855    /// **Not part of the public API.** Named with a leading underscore to
2856    /// signal that it is for generated-code use only.
2857    #[doc(hidden)]
2858    pub fn _decode_depth(
2859        buf: &'a [u8],
2860        depth: u32,
2861    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
2862        let mut view = Self::default();
2863        view._merge_into_view(buf, depth)?;
2864        ::core::result::Result::Ok(view)
2865    }
2866    /// Merge fields from `buf` into this view (proto merge semantics).
2867    ///
2868    /// Repeated fields append; singular fields last-wins; singular
2869    /// MESSAGE fields merge recursively. Used by sub-message decode
2870    /// arms when the same field appears multiple times on the wire.
2871    ///
2872    /// **Not part of the public API.**
2873    #[doc(hidden)]
2874    pub fn _merge_into_view(
2875        &mut self,
2876        buf: &'a [u8],
2877        depth: u32,
2878    ) -> ::core::result::Result<(), ::buffa::DecodeError> {
2879        let _ = depth;
2880        #[allow(unused_variables)]
2881        let view = self;
2882        let mut cur: &'a [u8] = buf;
2883        while !cur.is_empty() {
2884            let before_tag = cur;
2885            let tag = ::buffa::encoding::Tag::decode(&mut cur)?;
2886            match tag.field_number() {
2887                _ => {
2888                    ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?;
2889                    let span_len = before_tag.len() - cur.len();
2890                    view.__buffa_unknown_fields.push_raw(&before_tag[..span_len]);
2891                }
2892            }
2893        }
2894        ::core::result::Result::Ok(())
2895    }
2896}
2897impl<'a> ::buffa::MessageView<'a> for SequenceScopeView<'a> {
2898    type Owned = SequenceScope;
2899    fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
2900        Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT)
2901    }
2902    fn decode_view_with_limit(
2903        buf: &'a [u8],
2904        depth: u32,
2905    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
2906        Self::_decode_depth(buf, depth)
2907    }
2908    /// Convert this view to the owned message type.
2909    #[allow(clippy::redundant_closure, clippy::useless_conversion)]
2910    fn to_owned_message(&self) -> SequenceScope {
2911        #[allow(unused_imports)]
2912        use ::buffa::alloc::string::ToString as _;
2913        SequenceScope {
2914            __buffa_unknown_fields: self
2915                .__buffa_unknown_fields
2916                .to_owned()
2917                .unwrap_or_default()
2918                .into(),
2919            ..::core::default::Default::default()
2920        }
2921    }
2922}
2923unsafe impl ::buffa::DefaultViewInstance for SequenceScopeView<'static> {
2924    fn default_view_instance() -> &'static Self {
2925        static VALUE: ::buffa::__private::OnceBox<SequenceScopeView<'static>> = ::buffa::__private::OnceBox::new();
2926        VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default()))
2927    }
2928}
2929unsafe impl<'a> ::buffa::HasDefaultViewInstance for SequenceScopeView<'a> {
2930    type Static = SequenceScopeView<'static>;
2931}
2932/// A single prune policy. `scope` discriminates the keyspace the rule applies
2933/// to; `retain` is shared between scopes.
2934#[derive(Clone, PartialEq, Default)]
2935#[derive(::serde::Serialize)]
2936#[serde(default)]
2937pub struct Policy {
2938    /// Field 3: `retain`
2939    #[serde(
2940        rename = "retain",
2941        skip_serializing_if = "::buffa::json_helpers::skip_if::is_unset_message_field"
2942    )]
2943    pub retain: ::buffa::MessageField<PolicyRetain>,
2944    #[serde(flatten)]
2945    pub scope: Option<policy::Scope>,
2946    #[serde(skip)]
2947    #[doc(hidden)]
2948    pub __buffa_unknown_fields: ::buffa::UnknownFields,
2949    #[doc(hidden)]
2950    #[serde(skip)]
2951    pub __buffa_cached_size: ::buffa::__private::CachedSize,
2952}
2953impl ::core::fmt::Debug for Policy {
2954    fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
2955        f.debug_struct("Policy")
2956            .field("retain", &self.retain)
2957            .field("scope", &self.scope)
2958            .finish()
2959    }
2960}
2961impl Policy {
2962    /// Protobuf type URL for this message, for use with `Any::pack` and
2963    /// `Any::unpack_if`.
2964    ///
2965    /// Format: `type.googleapis.com/<fully.qualified.TypeName>`
2966    pub const TYPE_URL: &'static str = "type.googleapis.com/store.compact.v1.Policy";
2967}
2968unsafe impl ::buffa::DefaultInstance for Policy {
2969    fn default_instance() -> &'static Self {
2970        static VALUE: ::buffa::__private::OnceBox<Policy> = ::buffa::__private::OnceBox::new();
2971        VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default()))
2972    }
2973}
2974impl ::buffa::Message for Policy {
2975    /// Returns the total encoded size in bytes.
2976    ///
2977    /// The result is a `u32`; the protobuf specification requires all
2978    /// messages to fit within 2 GiB (2,147,483,647 bytes), so a
2979    /// compliant message will never overflow this type.
2980    fn compute_size(&self) -> u32 {
2981        #[allow(unused_imports)]
2982        use ::buffa::Enumeration as _;
2983        let mut size = 0u32;
2984        if self.retain.is_set() {
2985            let inner_size = self.retain.compute_size();
2986            size
2987                += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
2988                    + inner_size;
2989        }
2990        if let ::core::option::Option::Some(ref v) = self.scope {
2991            match v {
2992                policy::Scope::Keys(x) => {
2993                    let inner = x.compute_size();
2994                    size
2995                        += 1u32 + ::buffa::encoding::varint_len(inner as u64) as u32
2996                            + inner;
2997                }
2998                policy::Scope::Sequence(x) => {
2999                    let inner = x.compute_size();
3000                    size
3001                        += 1u32 + ::buffa::encoding::varint_len(inner as u64) as u32
3002                            + inner;
3003                }
3004            }
3005        }
3006        size += self.__buffa_unknown_fields.encoded_len() as u32;
3007        self.__buffa_cached_size.set(size);
3008        size
3009    }
3010    fn write_to(&self, buf: &mut impl ::buffa::bytes::BufMut) {
3011        #[allow(unused_imports)]
3012        use ::buffa::Enumeration as _;
3013        if self.retain.is_set() {
3014            ::buffa::encoding::Tag::new(
3015                    3u32,
3016                    ::buffa::encoding::WireType::LengthDelimited,
3017                )
3018                .encode(buf);
3019            ::buffa::encoding::encode_varint(self.retain.cached_size() as u64, buf);
3020            self.retain.write_to(buf);
3021        }
3022        if let ::core::option::Option::Some(ref v) = self.scope {
3023            match v {
3024                policy::Scope::Keys(x) => {
3025                    ::buffa::encoding::Tag::new(
3026                            1u32,
3027                            ::buffa::encoding::WireType::LengthDelimited,
3028                        )
3029                        .encode(buf);
3030                    ::buffa::encoding::encode_varint(x.cached_size() as u64, buf);
3031                    x.write_to(buf);
3032                }
3033                policy::Scope::Sequence(x) => {
3034                    ::buffa::encoding::Tag::new(
3035                            2u32,
3036                            ::buffa::encoding::WireType::LengthDelimited,
3037                        )
3038                        .encode(buf);
3039                    ::buffa::encoding::encode_varint(x.cached_size() as u64, buf);
3040                    x.write_to(buf);
3041                }
3042            }
3043        }
3044        self.__buffa_unknown_fields.write_to(buf);
3045    }
3046    fn merge_field(
3047        &mut self,
3048        tag: ::buffa::encoding::Tag,
3049        buf: &mut impl ::buffa::bytes::Buf,
3050        depth: u32,
3051    ) -> ::core::result::Result<(), ::buffa::DecodeError> {
3052        #[allow(unused_imports)]
3053        use ::buffa::bytes::Buf as _;
3054        #[allow(unused_imports)]
3055        use ::buffa::Enumeration as _;
3056        match tag.field_number() {
3057            3u32 => {
3058                if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
3059                    return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
3060                        field_number: 3u32,
3061                        expected: 2u8,
3062                        actual: tag.wire_type() as u8,
3063                    });
3064                }
3065                ::buffa::Message::merge_length_delimited(
3066                    self.retain.get_or_insert_default(),
3067                    buf,
3068                    depth,
3069                )?;
3070            }
3071            1u32 => {
3072                if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
3073                    return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
3074                        field_number: 1u32,
3075                        expected: 2u8,
3076                        actual: tag.wire_type() as u8,
3077                    });
3078                }
3079                if let ::core::option::Option::Some(
3080                    policy::Scope::Keys(ref mut existing),
3081                ) = self.scope
3082                {
3083                    ::buffa::Message::merge_length_delimited(
3084                        &mut **existing,
3085                        buf,
3086                        depth,
3087                    )?;
3088                } else {
3089                    let mut val = ::core::default::Default::default();
3090                    ::buffa::Message::merge_length_delimited(&mut val, buf, depth)?;
3091                    self.scope = ::core::option::Option::Some(
3092                        policy::Scope::Keys(::buffa::alloc::boxed::Box::new(val)),
3093                    );
3094                }
3095            }
3096            2u32 => {
3097                if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
3098                    return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
3099                        field_number: 2u32,
3100                        expected: 2u8,
3101                        actual: tag.wire_type() as u8,
3102                    });
3103                }
3104                if let ::core::option::Option::Some(
3105                    policy::Scope::Sequence(ref mut existing),
3106                ) = self.scope
3107                {
3108                    ::buffa::Message::merge_length_delimited(
3109                        &mut **existing,
3110                        buf,
3111                        depth,
3112                    )?;
3113                } else {
3114                    let mut val = ::core::default::Default::default();
3115                    ::buffa::Message::merge_length_delimited(&mut val, buf, depth)?;
3116                    self.scope = ::core::option::Option::Some(
3117                        policy::Scope::Sequence(::buffa::alloc::boxed::Box::new(val)),
3118                    );
3119                }
3120            }
3121            _ => {
3122                self.__buffa_unknown_fields
3123                    .push(::buffa::encoding::decode_unknown_field(tag, buf, depth)?);
3124            }
3125        }
3126        ::core::result::Result::Ok(())
3127    }
3128    fn cached_size(&self) -> u32 {
3129        self.__buffa_cached_size.get()
3130    }
3131    fn clear(&mut self) {
3132        self.retain = ::buffa::MessageField::none();
3133        self.scope = ::core::option::Option::None;
3134        self.__buffa_unknown_fields.clear();
3135        self.__buffa_cached_size.set(0);
3136    }
3137}
3138impl ::buffa::ExtensionSet for Policy {
3139    const PROTO_FQN: &'static str = "store.compact.v1.Policy";
3140    fn unknown_fields(&self) -> &::buffa::UnknownFields {
3141        &self.__buffa_unknown_fields
3142    }
3143    fn unknown_fields_mut(&mut self) -> &mut ::buffa::UnknownFields {
3144        &mut self.__buffa_unknown_fields
3145    }
3146}
3147impl<'de> serde::Deserialize<'de> for Policy {
3148    fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
3149        struct _V;
3150        impl<'de> serde::de::Visitor<'de> for _V {
3151            type Value = Policy;
3152            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
3153                f.write_str("struct Policy")
3154            }
3155            #[allow(clippy::field_reassign_with_default)]
3156            fn visit_map<A: serde::de::MapAccess<'de>>(
3157                self,
3158                mut map: A,
3159            ) -> Result<Policy, A::Error> {
3160                let mut __f_retain: Option<::buffa::MessageField<PolicyRetain>> = None;
3161                let mut __oneof_scope: Option<policy::Scope> = None;
3162                while let Some(key) = map.next_key::<::buffa::alloc::string::String>()? {
3163                    match key.as_str() {
3164                        "retain" => {
3165                            __f_retain = Some(
3166                                map.next_value::<::buffa::MessageField<PolicyRetain>>()?,
3167                            );
3168                        }
3169                        "keys" => {
3170                            let v: Option<KeysScope> = map
3171                                .next_value_seed(
3172                                    ::buffa::json_helpers::NullableDeserializeSeed(
3173                                        ::buffa::json_helpers::DefaultDeserializeSeed::<
3174                                            KeysScope,
3175                                        >::new(),
3176                                    ),
3177                                )?;
3178                            if let Some(v) = v {
3179                                if __oneof_scope.is_some() {
3180                                    return Err(
3181                                        serde::de::Error::custom(
3182                                            "multiple oneof fields set for 'scope'",
3183                                        ),
3184                                    );
3185                                }
3186                                __oneof_scope = Some(
3187                                    policy::Scope::Keys(::buffa::alloc::boxed::Box::new(v)),
3188                                );
3189                            }
3190                        }
3191                        "sequence" => {
3192                            let v: Option<SequenceScope> = map
3193                                .next_value_seed(
3194                                    ::buffa::json_helpers::NullableDeserializeSeed(
3195                                        ::buffa::json_helpers::DefaultDeserializeSeed::<
3196                                            SequenceScope,
3197                                        >::new(),
3198                                    ),
3199                                )?;
3200                            if let Some(v) = v {
3201                                if __oneof_scope.is_some() {
3202                                    return Err(
3203                                        serde::de::Error::custom(
3204                                            "multiple oneof fields set for 'scope'",
3205                                        ),
3206                                    );
3207                                }
3208                                __oneof_scope = Some(
3209                                    policy::Scope::Sequence(::buffa::alloc::boxed::Box::new(v)),
3210                                );
3211                            }
3212                        }
3213                        _ => {
3214                            map.next_value::<serde::de::IgnoredAny>()?;
3215                        }
3216                    }
3217                }
3218                let mut __r = <Policy as ::core::default::Default>::default();
3219                if let ::core::option::Option::Some(v) = __f_retain {
3220                    __r.retain = v;
3221                }
3222                __r.scope = __oneof_scope;
3223                Ok(__r)
3224            }
3225        }
3226        d.deserialize_map(_V)
3227    }
3228}
3229impl ::buffa::json_helpers::ProtoElemJson for Policy {
3230    fn serialize_proto_json<S: ::serde::Serializer>(
3231        v: &Self,
3232        s: S,
3233    ) -> ::core::result::Result<S::Ok, S::Error> {
3234        ::serde::Serialize::serialize(v, s)
3235    }
3236    fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>(
3237        d: D,
3238    ) -> ::core::result::Result<Self, D::Error> {
3239        <Self as ::serde::Deserialize>::deserialize(d)
3240    }
3241}
3242#[doc(hidden)]
3243pub const __POLICY_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry {
3244    type_url: "type.googleapis.com/store.compact.v1.Policy",
3245    to_json: ::buffa::type_registry::any_to_json::<Policy>,
3246    from_json: ::buffa::type_registry::any_from_json::<Policy>,
3247    is_wkt: false,
3248};
3249/// A single prune policy. `scope` discriminates the keyspace the rule applies
3250/// to; `retain` is shared between scopes.
3251#[derive(Clone, Debug, Default)]
3252pub struct PolicyView<'a> {
3253    /// Field 3: `retain`
3254    pub retain: ::buffa::MessageFieldView<PolicyRetainView<'a>>,
3255    pub scope: ::core::option::Option<policy::ScopeView<'a>>,
3256    pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
3257}
3258impl<'a> PolicyView<'a> {
3259    /// Decode from `buf`, enforcing a recursion depth limit for nested messages.
3260    ///
3261    /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`]
3262    /// and by generated sub-message decode arms with `depth - 1`.
3263    ///
3264    /// **Not part of the public API.** Named with a leading underscore to
3265    /// signal that it is for generated-code use only.
3266    #[doc(hidden)]
3267    pub fn _decode_depth(
3268        buf: &'a [u8],
3269        depth: u32,
3270    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
3271        let mut view = Self::default();
3272        view._merge_into_view(buf, depth)?;
3273        ::core::result::Result::Ok(view)
3274    }
3275    /// Merge fields from `buf` into this view (proto merge semantics).
3276    ///
3277    /// Repeated fields append; singular fields last-wins; singular
3278    /// MESSAGE fields merge recursively. Used by sub-message decode
3279    /// arms when the same field appears multiple times on the wire.
3280    ///
3281    /// **Not part of the public API.**
3282    #[doc(hidden)]
3283    pub fn _merge_into_view(
3284        &mut self,
3285        buf: &'a [u8],
3286        depth: u32,
3287    ) -> ::core::result::Result<(), ::buffa::DecodeError> {
3288        let _ = depth;
3289        #[allow(unused_variables)]
3290        let view = self;
3291        let mut cur: &'a [u8] = buf;
3292        while !cur.is_empty() {
3293            let before_tag = cur;
3294            let tag = ::buffa::encoding::Tag::decode(&mut cur)?;
3295            match tag.field_number() {
3296                3u32 => {
3297                    if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
3298                        return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
3299                            field_number: 3u32,
3300                            expected: 2u8,
3301                            actual: tag.wire_type() as u8,
3302                        });
3303                    }
3304                    if depth == 0 {
3305                        return Err(::buffa::DecodeError::RecursionLimitExceeded);
3306                    }
3307                    let sub = ::buffa::types::borrow_bytes(&mut cur)?;
3308                    match view.retain.as_mut() {
3309                        Some(existing) => existing._merge_into_view(sub, depth - 1)?,
3310                        None => {
3311                            view.retain = ::buffa::MessageFieldView::set(
3312                                PolicyRetainView::_decode_depth(sub, depth - 1)?,
3313                            );
3314                        }
3315                    }
3316                }
3317                1u32 => {
3318                    if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
3319                        return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
3320                            field_number: 1u32,
3321                            expected: 2u8,
3322                            actual: tag.wire_type() as u8,
3323                        });
3324                    }
3325                    if depth == 0 {
3326                        return Err(::buffa::DecodeError::RecursionLimitExceeded);
3327                    }
3328                    let sub = ::buffa::types::borrow_bytes(&mut cur)?;
3329                    if let Some(policy::ScopeView::Keys(ref mut existing)) = view.scope {
3330                        existing._merge_into_view(sub, depth - 1)?;
3331                    } else {
3332                        view.scope = Some(
3333                            policy::ScopeView::Keys(
3334                                ::buffa::alloc::boxed::Box::new(
3335                                    KeysScopeView::_decode_depth(sub, depth - 1)?,
3336                                ),
3337                            ),
3338                        );
3339                    }
3340                }
3341                2u32 => {
3342                    if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
3343                        return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
3344                            field_number: 2u32,
3345                            expected: 2u8,
3346                            actual: tag.wire_type() as u8,
3347                        });
3348                    }
3349                    if depth == 0 {
3350                        return Err(::buffa::DecodeError::RecursionLimitExceeded);
3351                    }
3352                    let sub = ::buffa::types::borrow_bytes(&mut cur)?;
3353                    if let Some(policy::ScopeView::Sequence(ref mut existing)) = view
3354                        .scope
3355                    {
3356                        existing._merge_into_view(sub, depth - 1)?;
3357                    } else {
3358                        view.scope = Some(
3359                            policy::ScopeView::Sequence(
3360                                ::buffa::alloc::boxed::Box::new(
3361                                    SequenceScopeView::_decode_depth(sub, depth - 1)?,
3362                                ),
3363                            ),
3364                        );
3365                    }
3366                }
3367                _ => {
3368                    ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?;
3369                    let span_len = before_tag.len() - cur.len();
3370                    view.__buffa_unknown_fields.push_raw(&before_tag[..span_len]);
3371                }
3372            }
3373        }
3374        ::core::result::Result::Ok(())
3375    }
3376}
3377impl<'a> ::buffa::MessageView<'a> for PolicyView<'a> {
3378    type Owned = Policy;
3379    fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
3380        Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT)
3381    }
3382    fn decode_view_with_limit(
3383        buf: &'a [u8],
3384        depth: u32,
3385    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
3386        Self::_decode_depth(buf, depth)
3387    }
3388    /// Convert this view to the owned message type.
3389    #[allow(clippy::redundant_closure, clippy::useless_conversion)]
3390    fn to_owned_message(&self) -> Policy {
3391        #[allow(unused_imports)]
3392        use ::buffa::alloc::string::ToString as _;
3393        Policy {
3394            retain: match self.retain.as_option() {
3395                Some(v) => {
3396                    ::buffa::MessageField::<PolicyRetain>::some(v.to_owned_message())
3397                }
3398                None => ::buffa::MessageField::none(),
3399            },
3400            scope: self
3401                .scope
3402                .as_ref()
3403                .map(|v| match v {
3404                    policy::ScopeView::Keys(v) => {
3405                        policy::Scope::Keys(
3406                            ::buffa::alloc::boxed::Box::new(v.to_owned_message()),
3407                        )
3408                    }
3409                    policy::ScopeView::Sequence(v) => {
3410                        policy::Scope::Sequence(
3411                            ::buffa::alloc::boxed::Box::new(v.to_owned_message()),
3412                        )
3413                    }
3414                }),
3415            __buffa_unknown_fields: self
3416                .__buffa_unknown_fields
3417                .to_owned()
3418                .unwrap_or_default()
3419                .into(),
3420            ..::core::default::Default::default()
3421        }
3422    }
3423}
3424unsafe impl ::buffa::DefaultViewInstance for PolicyView<'static> {
3425    fn default_view_instance() -> &'static Self {
3426        static VALUE: ::buffa::__private::OnceBox<PolicyView<'static>> = ::buffa::__private::OnceBox::new();
3427        VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default()))
3428    }
3429}
3430unsafe impl<'a> ::buffa::HasDefaultViewInstance for PolicyView<'a> {
3431    type Static = PolicyView<'static>;
3432}
3433pub mod policy {
3434    #[allow(unused_imports)]
3435    use super::*;
3436    #[derive(Clone, PartialEq, Debug)]
3437    pub enum Scope {
3438        Keys(::buffa::alloc::boxed::Box<super::KeysScope>),
3439        Sequence(::buffa::alloc::boxed::Box<super::SequenceScope>),
3440    }
3441    impl ::buffa::Oneof for Scope {}
3442    impl From<super::KeysScope> for Scope {
3443        fn from(v: super::KeysScope) -> Self {
3444            Self::Keys(::buffa::alloc::boxed::Box::new(v))
3445        }
3446    }
3447    impl From<super::KeysScope> for ::core::option::Option<Scope> {
3448        fn from(v: super::KeysScope) -> Self {
3449            Self::Some(Scope::from(v))
3450        }
3451    }
3452    impl From<super::SequenceScope> for Scope {
3453        fn from(v: super::SequenceScope) -> Self {
3454            Self::Sequence(::buffa::alloc::boxed::Box::new(v))
3455        }
3456    }
3457    impl From<super::SequenceScope> for ::core::option::Option<Scope> {
3458        fn from(v: super::SequenceScope) -> Self {
3459            Self::Some(Scope::from(v))
3460        }
3461    }
3462    impl serde::Serialize for Scope {
3463        fn serialize<S: serde::Serializer>(
3464            &self,
3465            s: S,
3466        ) -> ::core::result::Result<S::Ok, S::Error> {
3467            use serde::ser::SerializeMap;
3468            let mut map = s.serialize_map(Some(1))?;
3469            match self {
3470                Scope::Keys(v) => {
3471                    map.serialize_entry("keys", v)?;
3472                }
3473                Scope::Sequence(v) => {
3474                    map.serialize_entry("sequence", v)?;
3475                }
3476            }
3477            map.end()
3478        }
3479    }
3480    #[derive(Clone, Debug)]
3481    pub enum ScopeView<'a> {
3482        Keys(::buffa::alloc::boxed::Box<super::KeysScopeView<'a>>),
3483        Sequence(::buffa::alloc::boxed::Box<super::SequenceScopeView<'a>>),
3484    }
3485}
3486/// Request to execute prune policies.
3487#[derive(Clone, PartialEq, Default)]
3488#[derive(::serde::Serialize, ::serde::Deserialize)]
3489#[serde(default)]
3490pub struct PruneRequest {
3491    /// One or more prune policies to apply. At least one is required. UserKeys
3492    /// policies must not share the same (reserved_bits, prefix) pair.
3493    ///
3494    /// Field 1: `policies`
3495    #[serde(
3496        rename = "policies",
3497        skip_serializing_if = "::buffa::json_helpers::skip_if::is_empty_vec",
3498        deserialize_with = "::buffa::json_helpers::null_as_default"
3499    )]
3500    pub policies: ::buffa::alloc::vec::Vec<Policy>,
3501    #[serde(skip)]
3502    #[doc(hidden)]
3503    pub __buffa_unknown_fields: ::buffa::UnknownFields,
3504    #[doc(hidden)]
3505    #[serde(skip)]
3506    pub __buffa_cached_size: ::buffa::__private::CachedSize,
3507}
3508impl ::core::fmt::Debug for PruneRequest {
3509    fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
3510        f.debug_struct("PruneRequest").field("policies", &self.policies).finish()
3511    }
3512}
3513impl PruneRequest {
3514    /// Protobuf type URL for this message, for use with `Any::pack` and
3515    /// `Any::unpack_if`.
3516    ///
3517    /// Format: `type.googleapis.com/<fully.qualified.TypeName>`
3518    pub const TYPE_URL: &'static str = "type.googleapis.com/store.compact.v1.PruneRequest";
3519}
3520unsafe impl ::buffa::DefaultInstance for PruneRequest {
3521    fn default_instance() -> &'static Self {
3522        static VALUE: ::buffa::__private::OnceBox<PruneRequest> = ::buffa::__private::OnceBox::new();
3523        VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default()))
3524    }
3525}
3526impl ::buffa::Message for PruneRequest {
3527    /// Returns the total encoded size in bytes.
3528    ///
3529    /// The result is a `u32`; the protobuf specification requires all
3530    /// messages to fit within 2 GiB (2,147,483,647 bytes), so a
3531    /// compliant message will never overflow this type.
3532    fn compute_size(&self) -> u32 {
3533        #[allow(unused_imports)]
3534        use ::buffa::Enumeration as _;
3535        let mut size = 0u32;
3536        for v in &self.policies {
3537            let inner_size = v.compute_size();
3538            size
3539                += 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
3540                    + inner_size;
3541        }
3542        size += self.__buffa_unknown_fields.encoded_len() as u32;
3543        self.__buffa_cached_size.set(size);
3544        size
3545    }
3546    fn write_to(&self, buf: &mut impl ::buffa::bytes::BufMut) {
3547        #[allow(unused_imports)]
3548        use ::buffa::Enumeration as _;
3549        for v in &self.policies {
3550            ::buffa::encoding::Tag::new(
3551                    1u32,
3552                    ::buffa::encoding::WireType::LengthDelimited,
3553                )
3554                .encode(buf);
3555            ::buffa::encoding::encode_varint(v.cached_size() as u64, buf);
3556            v.write_to(buf);
3557        }
3558        self.__buffa_unknown_fields.write_to(buf);
3559    }
3560    fn merge_field(
3561        &mut self,
3562        tag: ::buffa::encoding::Tag,
3563        buf: &mut impl ::buffa::bytes::Buf,
3564        depth: u32,
3565    ) -> ::core::result::Result<(), ::buffa::DecodeError> {
3566        #[allow(unused_imports)]
3567        use ::buffa::bytes::Buf as _;
3568        #[allow(unused_imports)]
3569        use ::buffa::Enumeration as _;
3570        match tag.field_number() {
3571            1u32 => {
3572                if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
3573                    return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
3574                        field_number: 1u32,
3575                        expected: 2u8,
3576                        actual: tag.wire_type() as u8,
3577                    });
3578                }
3579                let mut elem = ::core::default::Default::default();
3580                ::buffa::Message::merge_length_delimited(&mut elem, buf, depth)?;
3581                self.policies.push(elem);
3582            }
3583            _ => {
3584                self.__buffa_unknown_fields
3585                    .push(::buffa::encoding::decode_unknown_field(tag, buf, depth)?);
3586            }
3587        }
3588        ::core::result::Result::Ok(())
3589    }
3590    fn cached_size(&self) -> u32 {
3591        self.__buffa_cached_size.get()
3592    }
3593    fn clear(&mut self) {
3594        self.policies.clear();
3595        self.__buffa_unknown_fields.clear();
3596        self.__buffa_cached_size.set(0);
3597    }
3598}
3599impl ::buffa::ExtensionSet for PruneRequest {
3600    const PROTO_FQN: &'static str = "store.compact.v1.PruneRequest";
3601    fn unknown_fields(&self) -> &::buffa::UnknownFields {
3602        &self.__buffa_unknown_fields
3603    }
3604    fn unknown_fields_mut(&mut self) -> &mut ::buffa::UnknownFields {
3605        &mut self.__buffa_unknown_fields
3606    }
3607}
3608impl ::buffa::json_helpers::ProtoElemJson for PruneRequest {
3609    fn serialize_proto_json<S: ::serde::Serializer>(
3610        v: &Self,
3611        s: S,
3612    ) -> ::core::result::Result<S::Ok, S::Error> {
3613        ::serde::Serialize::serialize(v, s)
3614    }
3615    fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>(
3616        d: D,
3617    ) -> ::core::result::Result<Self, D::Error> {
3618        <Self as ::serde::Deserialize>::deserialize(d)
3619    }
3620}
3621#[doc(hidden)]
3622pub const __PRUNE_REQUEST_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry {
3623    type_url: "type.googleapis.com/store.compact.v1.PruneRequest",
3624    to_json: ::buffa::type_registry::any_to_json::<PruneRequest>,
3625    from_json: ::buffa::type_registry::any_from_json::<PruneRequest>,
3626    is_wkt: false,
3627};
3628/// Request to execute prune policies.
3629#[derive(Clone, Debug, Default)]
3630pub struct PruneRequestView<'a> {
3631    /// One or more prune policies to apply. At least one is required. UserKeys
3632    /// policies must not share the same (reserved_bits, prefix) pair.
3633    ///
3634    /// Field 1: `policies`
3635    pub policies: ::buffa::RepeatedView<'a, PolicyView<'a>>,
3636    pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
3637}
3638impl<'a> PruneRequestView<'a> {
3639    /// Decode from `buf`, enforcing a recursion depth limit for nested messages.
3640    ///
3641    /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`]
3642    /// and by generated sub-message decode arms with `depth - 1`.
3643    ///
3644    /// **Not part of the public API.** Named with a leading underscore to
3645    /// signal that it is for generated-code use only.
3646    #[doc(hidden)]
3647    pub fn _decode_depth(
3648        buf: &'a [u8],
3649        depth: u32,
3650    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
3651        let mut view = Self::default();
3652        view._merge_into_view(buf, depth)?;
3653        ::core::result::Result::Ok(view)
3654    }
3655    /// Merge fields from `buf` into this view (proto merge semantics).
3656    ///
3657    /// Repeated fields append; singular fields last-wins; singular
3658    /// MESSAGE fields merge recursively. Used by sub-message decode
3659    /// arms when the same field appears multiple times on the wire.
3660    ///
3661    /// **Not part of the public API.**
3662    #[doc(hidden)]
3663    pub fn _merge_into_view(
3664        &mut self,
3665        buf: &'a [u8],
3666        depth: u32,
3667    ) -> ::core::result::Result<(), ::buffa::DecodeError> {
3668        let _ = depth;
3669        #[allow(unused_variables)]
3670        let view = self;
3671        let mut cur: &'a [u8] = buf;
3672        while !cur.is_empty() {
3673            let before_tag = cur;
3674            let tag = ::buffa::encoding::Tag::decode(&mut cur)?;
3675            match tag.field_number() {
3676                1u32 => {
3677                    if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
3678                        return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
3679                            field_number: 1u32,
3680                            expected: 2u8,
3681                            actual: tag.wire_type() as u8,
3682                        });
3683                    }
3684                    if depth == 0 {
3685                        return Err(::buffa::DecodeError::RecursionLimitExceeded);
3686                    }
3687                    let sub = ::buffa::types::borrow_bytes(&mut cur)?;
3688                    view.policies.push(PolicyView::_decode_depth(sub, depth - 1)?);
3689                }
3690                _ => {
3691                    ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?;
3692                    let span_len = before_tag.len() - cur.len();
3693                    view.__buffa_unknown_fields.push_raw(&before_tag[..span_len]);
3694                }
3695            }
3696        }
3697        ::core::result::Result::Ok(())
3698    }
3699}
3700impl<'a> ::buffa::MessageView<'a> for PruneRequestView<'a> {
3701    type Owned = PruneRequest;
3702    fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
3703        Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT)
3704    }
3705    fn decode_view_with_limit(
3706        buf: &'a [u8],
3707        depth: u32,
3708    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
3709        Self::_decode_depth(buf, depth)
3710    }
3711    /// Convert this view to the owned message type.
3712    #[allow(clippy::redundant_closure, clippy::useless_conversion)]
3713    fn to_owned_message(&self) -> PruneRequest {
3714        #[allow(unused_imports)]
3715        use ::buffa::alloc::string::ToString as _;
3716        PruneRequest {
3717            policies: self.policies.iter().map(|v| v.to_owned_message()).collect(),
3718            __buffa_unknown_fields: self
3719                .__buffa_unknown_fields
3720                .to_owned()
3721                .unwrap_or_default()
3722                .into(),
3723            ..::core::default::Default::default()
3724        }
3725    }
3726}
3727unsafe impl ::buffa::DefaultViewInstance for PruneRequestView<'static> {
3728    fn default_view_instance() -> &'static Self {
3729        static VALUE: ::buffa::__private::OnceBox<PruneRequestView<'static>> = ::buffa::__private::OnceBox::new();
3730        VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default()))
3731    }
3732}
3733unsafe impl<'a> ::buffa::HasDefaultViewInstance for PruneRequestView<'a> {
3734    type Static = PruneRequestView<'static>;
3735}
3736/// Empty response returned on successful prune execution.
3737#[derive(Clone, PartialEq, Default)]
3738#[derive(::serde::Serialize, ::serde::Deserialize)]
3739#[serde(default)]
3740pub struct PruneResponse {
3741    #[serde(skip)]
3742    #[doc(hidden)]
3743    pub __buffa_unknown_fields: ::buffa::UnknownFields,
3744    #[doc(hidden)]
3745    #[serde(skip)]
3746    pub __buffa_cached_size: ::buffa::__private::CachedSize,
3747}
3748impl ::core::fmt::Debug for PruneResponse {
3749    fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
3750        f.debug_struct("PruneResponse").finish()
3751    }
3752}
3753impl PruneResponse {
3754    /// Protobuf type URL for this message, for use with `Any::pack` and
3755    /// `Any::unpack_if`.
3756    ///
3757    /// Format: `type.googleapis.com/<fully.qualified.TypeName>`
3758    pub const TYPE_URL: &'static str = "type.googleapis.com/store.compact.v1.PruneResponse";
3759}
3760unsafe impl ::buffa::DefaultInstance for PruneResponse {
3761    fn default_instance() -> &'static Self {
3762        static VALUE: ::buffa::__private::OnceBox<PruneResponse> = ::buffa::__private::OnceBox::new();
3763        VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default()))
3764    }
3765}
3766impl ::buffa::Message for PruneResponse {
3767    /// Returns the total encoded size in bytes.
3768    ///
3769    /// The result is a `u32`; the protobuf specification requires all
3770    /// messages to fit within 2 GiB (2,147,483,647 bytes), so a
3771    /// compliant message will never overflow this type.
3772    fn compute_size(&self) -> u32 {
3773        #[allow(unused_imports)]
3774        use ::buffa::Enumeration as _;
3775        let mut size = 0u32;
3776        size += self.__buffa_unknown_fields.encoded_len() as u32;
3777        self.__buffa_cached_size.set(size);
3778        size
3779    }
3780    fn write_to(&self, buf: &mut impl ::buffa::bytes::BufMut) {
3781        #[allow(unused_imports)]
3782        use ::buffa::Enumeration as _;
3783        self.__buffa_unknown_fields.write_to(buf);
3784    }
3785    fn merge_field(
3786        &mut self,
3787        tag: ::buffa::encoding::Tag,
3788        buf: &mut impl ::buffa::bytes::Buf,
3789        depth: u32,
3790    ) -> ::core::result::Result<(), ::buffa::DecodeError> {
3791        #[allow(unused_imports)]
3792        use ::buffa::bytes::Buf as _;
3793        #[allow(unused_imports)]
3794        use ::buffa::Enumeration as _;
3795        match tag.field_number() {
3796            _ => {
3797                self.__buffa_unknown_fields
3798                    .push(::buffa::encoding::decode_unknown_field(tag, buf, depth)?);
3799            }
3800        }
3801        ::core::result::Result::Ok(())
3802    }
3803    fn cached_size(&self) -> u32 {
3804        self.__buffa_cached_size.get()
3805    }
3806    fn clear(&mut self) {
3807        self.__buffa_unknown_fields.clear();
3808        self.__buffa_cached_size.set(0);
3809    }
3810}
3811impl ::buffa::ExtensionSet for PruneResponse {
3812    const PROTO_FQN: &'static str = "store.compact.v1.PruneResponse";
3813    fn unknown_fields(&self) -> &::buffa::UnknownFields {
3814        &self.__buffa_unknown_fields
3815    }
3816    fn unknown_fields_mut(&mut self) -> &mut ::buffa::UnknownFields {
3817        &mut self.__buffa_unknown_fields
3818    }
3819}
3820impl ::buffa::json_helpers::ProtoElemJson for PruneResponse {
3821    fn serialize_proto_json<S: ::serde::Serializer>(
3822        v: &Self,
3823        s: S,
3824    ) -> ::core::result::Result<S::Ok, S::Error> {
3825        ::serde::Serialize::serialize(v, s)
3826    }
3827    fn deserialize_proto_json<'de, D: ::serde::Deserializer<'de>>(
3828        d: D,
3829    ) -> ::core::result::Result<Self, D::Error> {
3830        <Self as ::serde::Deserialize>::deserialize(d)
3831    }
3832}
3833#[doc(hidden)]
3834pub const __PRUNE_RESPONSE_JSON_ANY: ::buffa::type_registry::JsonAnyEntry = ::buffa::type_registry::JsonAnyEntry {
3835    type_url: "type.googleapis.com/store.compact.v1.PruneResponse",
3836    to_json: ::buffa::type_registry::any_to_json::<PruneResponse>,
3837    from_json: ::buffa::type_registry::any_from_json::<PruneResponse>,
3838    is_wkt: false,
3839};
3840/// Empty response returned on successful prune execution.
3841#[derive(Clone, Debug, Default)]
3842pub struct PruneResponseView<'a> {
3843    pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
3844}
3845impl<'a> PruneResponseView<'a> {
3846    /// Decode from `buf`, enforcing a recursion depth limit for nested messages.
3847    ///
3848    /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`]
3849    /// and by generated sub-message decode arms with `depth - 1`.
3850    ///
3851    /// **Not part of the public API.** Named with a leading underscore to
3852    /// signal that it is for generated-code use only.
3853    #[doc(hidden)]
3854    pub fn _decode_depth(
3855        buf: &'a [u8],
3856        depth: u32,
3857    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
3858        let mut view = Self::default();
3859        view._merge_into_view(buf, depth)?;
3860        ::core::result::Result::Ok(view)
3861    }
3862    /// Merge fields from `buf` into this view (proto merge semantics).
3863    ///
3864    /// Repeated fields append; singular fields last-wins; singular
3865    /// MESSAGE fields merge recursively. Used by sub-message decode
3866    /// arms when the same field appears multiple times on the wire.
3867    ///
3868    /// **Not part of the public API.**
3869    #[doc(hidden)]
3870    pub fn _merge_into_view(
3871        &mut self,
3872        buf: &'a [u8],
3873        depth: u32,
3874    ) -> ::core::result::Result<(), ::buffa::DecodeError> {
3875        let _ = depth;
3876        #[allow(unused_variables)]
3877        let view = self;
3878        let mut cur: &'a [u8] = buf;
3879        while !cur.is_empty() {
3880            let before_tag = cur;
3881            let tag = ::buffa::encoding::Tag::decode(&mut cur)?;
3882            match tag.field_number() {
3883                _ => {
3884                    ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?;
3885                    let span_len = before_tag.len() - cur.len();
3886                    view.__buffa_unknown_fields.push_raw(&before_tag[..span_len]);
3887                }
3888            }
3889        }
3890        ::core::result::Result::Ok(())
3891    }
3892}
3893impl<'a> ::buffa::MessageView<'a> for PruneResponseView<'a> {
3894    type Owned = PruneResponse;
3895    fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
3896        Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT)
3897    }
3898    fn decode_view_with_limit(
3899        buf: &'a [u8],
3900        depth: u32,
3901    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
3902        Self::_decode_depth(buf, depth)
3903    }
3904    /// Convert this view to the owned message type.
3905    #[allow(clippy::redundant_closure, clippy::useless_conversion)]
3906    fn to_owned_message(&self) -> PruneResponse {
3907        #[allow(unused_imports)]
3908        use ::buffa::alloc::string::ToString as _;
3909        PruneResponse {
3910            __buffa_unknown_fields: self
3911                .__buffa_unknown_fields
3912                .to_owned()
3913                .unwrap_or_default()
3914                .into(),
3915            ..::core::default::Default::default()
3916        }
3917    }
3918}
3919unsafe impl ::buffa::DefaultViewInstance for PruneResponseView<'static> {
3920    fn default_view_instance() -> &'static Self {
3921        static VALUE: ::buffa::__private::OnceBox<PruneResponseView<'static>> = ::buffa::__private::OnceBox::new();
3922        VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default()))
3923    }
3924}
3925unsafe impl<'a> ::buffa::HasDefaultViewInstance for PruneResponseView<'a> {
3926    type Static = PruneResponseView<'static>;
3927}
3928
3929/// Full service name for this service.
3930pub const SERVICE_SERVICE_NAME: &str = "store.compact.v1.Service";
3931/// Compaction service, typically served by the compaction worker.
3932///
3933/// # Implementing handlers
3934///
3935/// Handlers receive requests as `OwnedView<FooView<'static>>`, which gives
3936/// zero-copy borrowed access to fields (e.g. `request.name` is a `&str`
3937/// into the decoded buffer). The view can be held across `.await` points.
3938///
3939/// Implement methods with plain `async fn`; the returned future satisfies
3940/// the `Send` bound automatically. See the
3941/// [buffa user guide](https://github.com/anthropics/buffa/blob/main/docs/guide.md#ownedview-in-async-trait-implementations)
3942/// for zero-copy access patterns and when `to_owned_message()` is needed.
3943#[allow(clippy::type_complexity)]
3944pub trait Service: Send + Sync + 'static {
3945    /// Execute one or more prune policies against the store. Each policy is
3946    /// applied sequentially.
3947    fn prune(
3948        &self,
3949        ctx: ::connectrpc::Context,
3950        request: ::buffa::view::OwnedView<PruneRequestView<'static>>,
3951    ) -> impl ::std::future::Future<
3952        Output = Result<
3953            (PruneResponse, ::connectrpc::Context),
3954            ::connectrpc::ConnectError,
3955        >,
3956    > + Send;
3957}
3958/// Extension trait for registering a service implementation with a Router.
3959///
3960/// This trait is automatically implemented for all types that implement the service trait.
3961///
3962/// # Example
3963///
3964/// ```rust,ignore
3965/// use std::sync::Arc;
3966///
3967/// let service = Arc::new(MyServiceImpl);
3968/// let router = service.register(Router::new());
3969/// ```
3970pub trait ServiceExt: Service {
3971    /// Register this service implementation with a Router.
3972    ///
3973    /// Takes ownership of the `Arc<Self>` and returns a new Router with
3974    /// this service's methods registered.
3975    fn register(
3976        self: ::std::sync::Arc<Self>,
3977        router: ::connectrpc::Router,
3978    ) -> ::connectrpc::Router;
3979}
3980impl<S: Service> ServiceExt for S {
3981    fn register(
3982        self: ::std::sync::Arc<Self>,
3983        router: ::connectrpc::Router,
3984    ) -> ::connectrpc::Router {
3985        router
3986            .route_view(
3987                SERVICE_SERVICE_NAME,
3988                "Prune",
3989                {
3990                    let svc = ::std::sync::Arc::clone(&self);
3991                    ::connectrpc::view_handler_fn(move |ctx, req| {
3992                        let svc = ::std::sync::Arc::clone(&svc);
3993                        async move { svc.prune(ctx, req).await }
3994                    })
3995                },
3996            )
3997    }
3998}
3999/// Monomorphic dispatcher for `Service`.
4000///
4001/// 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.
4002///
4003/// # Example
4004///
4005/// ```rust,ignore
4006/// use connectrpc::ConnectRpcService;
4007///
4008/// let server = ServiceServer::new(MyImpl);
4009/// let service = ConnectRpcService::new(server);
4010/// // hand `service` to axum/hyper as a fallback_service
4011/// ```
4012pub struct ServiceServer<T> {
4013    inner: ::std::sync::Arc<T>,
4014}
4015impl<T: Service> ServiceServer<T> {
4016    /// Wrap a service implementation in a monomorphic dispatcher.
4017    pub fn new(service: T) -> Self {
4018        Self {
4019            inner: ::std::sync::Arc::new(service),
4020        }
4021    }
4022    /// Wrap an already-`Arc`'d service implementation.
4023    pub fn from_arc(inner: ::std::sync::Arc<T>) -> Self {
4024        Self { inner }
4025    }
4026}
4027impl<T> Clone for ServiceServer<T> {
4028    fn clone(&self) -> Self {
4029        Self {
4030            inner: ::std::sync::Arc::clone(&self.inner),
4031        }
4032    }
4033}
4034impl<T: Service> ::connectrpc::Dispatcher for ServiceServer<T> {
4035    #[inline]
4036    fn lookup(
4037        &self,
4038        path: &str,
4039    ) -> Option<::connectrpc::dispatcher::codegen::MethodDescriptor> {
4040        let method = path.strip_prefix("store.compact.v1.Service/")?;
4041        match method {
4042            "Prune" => {
4043                Some(::connectrpc::dispatcher::codegen::MethodDescriptor::unary(false))
4044            }
4045            _ => None,
4046        }
4047    }
4048    fn call_unary(
4049        &self,
4050        path: &str,
4051        ctx: ::connectrpc::Context,
4052        request: ::buffa::bytes::Bytes,
4053        format: ::connectrpc::CodecFormat,
4054    ) -> ::connectrpc::dispatcher::codegen::UnaryResult {
4055        let Some(method) = path.strip_prefix("store.compact.v1.Service/") else {
4056            return ::connectrpc::dispatcher::codegen::unimplemented_unary(path);
4057        };
4058        let _ = (&ctx, &request, &format);
4059        match method {
4060            "Prune" => {
4061                let svc = ::std::sync::Arc::clone(&self.inner);
4062                Box::pin(async move {
4063                    let req = ::connectrpc::dispatcher::codegen::decode_request_view::<
4064                        PruneRequestView,
4065                    >(request, format)?;
4066                    let (res, ctx) = svc.prune(ctx, req).await?;
4067                    let bytes = ::connectrpc::dispatcher::codegen::encode_response(
4068                        &res,
4069                        format,
4070                    )?;
4071                    Ok((bytes, ctx))
4072                })
4073            }
4074            _ => ::connectrpc::dispatcher::codegen::unimplemented_unary(path),
4075        }
4076    }
4077    fn call_server_streaming(
4078        &self,
4079        path: &str,
4080        ctx: ::connectrpc::Context,
4081        request: ::buffa::bytes::Bytes,
4082        format: ::connectrpc::CodecFormat,
4083    ) -> ::connectrpc::dispatcher::codegen::StreamingResult {
4084        let Some(method) = path.strip_prefix("store.compact.v1.Service/") else {
4085            return ::connectrpc::dispatcher::codegen::unimplemented_streaming(path);
4086        };
4087        let _ = (&ctx, &request, &format);
4088        match method {
4089            _ => ::connectrpc::dispatcher::codegen::unimplemented_streaming(path),
4090        }
4091    }
4092    fn call_client_streaming(
4093        &self,
4094        path: &str,
4095        ctx: ::connectrpc::Context,
4096        requests: ::connectrpc::dispatcher::codegen::RequestStream,
4097        format: ::connectrpc::CodecFormat,
4098    ) -> ::connectrpc::dispatcher::codegen::UnaryResult {
4099        let Some(method) = path.strip_prefix("store.compact.v1.Service/") else {
4100            return ::connectrpc::dispatcher::codegen::unimplemented_unary(path);
4101        };
4102        let _ = (&ctx, &requests, &format);
4103        match method {
4104            _ => ::connectrpc::dispatcher::codegen::unimplemented_unary(path),
4105        }
4106    }
4107    fn call_bidi_streaming(
4108        &self,
4109        path: &str,
4110        ctx: ::connectrpc::Context,
4111        requests: ::connectrpc::dispatcher::codegen::RequestStream,
4112        format: ::connectrpc::CodecFormat,
4113    ) -> ::connectrpc::dispatcher::codegen::StreamingResult {
4114        let Some(method) = path.strip_prefix("store.compact.v1.Service/") else {
4115            return ::connectrpc::dispatcher::codegen::unimplemented_streaming(path);
4116        };
4117        let _ = (&ctx, &requests, &format);
4118        match method {
4119            _ => ::connectrpc::dispatcher::codegen::unimplemented_streaming(path),
4120        }
4121    }
4122}
4123/// Client for this service.
4124///
4125/// Generic over `T: ClientTransport`. For **gRPC** (HTTP/2), use
4126/// `Http2Connection` — it has honest `poll_ready` and composes with
4127/// `tower::balance` for multi-connection load balancing. For **Connect
4128/// over HTTP/1.1** (or unknown protocol), use `HttpClient`.
4129///
4130/// # Example (gRPC / HTTP/2)
4131///
4132/// ```rust,ignore
4133/// use connectrpc::client::{Http2Connection, ClientConfig};
4134/// use connectrpc::Protocol;
4135///
4136/// let uri: http::Uri = "http://localhost:8080".parse()?;
4137/// let conn = Http2Connection::connect_plaintext(uri.clone()).await?.shared(1024);
4138/// let config = ClientConfig::new(uri).protocol(Protocol::Grpc);
4139///
4140/// let client = ServiceClient::new(conn, config);
4141/// let response = client.prune(request).await?;
4142/// ```
4143///
4144/// # Example (Connect / HTTP/1.1 or ALPN)
4145///
4146/// ```rust,ignore
4147/// use connectrpc::client::{HttpClient, ClientConfig};
4148///
4149/// let http = HttpClient::plaintext();  // cleartext http:// only
4150/// let config = ClientConfig::new("http://localhost:8080".parse()?);
4151///
4152/// let client = ServiceClient::new(http, config);
4153/// let response = client.prune(request).await?;
4154/// ```
4155///
4156/// # Working with the response
4157///
4158/// Unary calls return [`UnaryResponse<OwnedView<FooView>>`](::connectrpc::client::UnaryResponse).
4159/// The `OwnedView` derefs to the view, so field access is zero-copy:
4160///
4161/// ```rust,ignore
4162/// let resp = client.prune(request).await?.into_view();
4163/// let name: &str = resp.name;  // borrow into the response buffer
4164/// ```
4165///
4166/// If you need the owned struct (e.g. to store or pass by value), use
4167/// [`into_owned()`](::connectrpc::client::UnaryResponse::into_owned):
4168///
4169/// ```rust,ignore
4170/// let owned = client.prune(request).await?.into_owned();
4171/// ```
4172#[derive(Clone)]
4173pub struct ServiceClient<T> {
4174    transport: T,
4175    config: ::connectrpc::client::ClientConfig,
4176}
4177impl<T> ServiceClient<T>
4178where
4179    T: ::connectrpc::client::ClientTransport,
4180    <T::ResponseBody as ::http_body::Body>::Error: ::std::fmt::Display,
4181{
4182    /// Create a new client with the given transport and configuration.
4183    pub fn new(transport: T, config: ::connectrpc::client::ClientConfig) -> Self {
4184        Self { transport, config }
4185    }
4186    /// Get the client configuration.
4187    pub fn config(&self) -> &::connectrpc::client::ClientConfig {
4188        &self.config
4189    }
4190    /// Get a mutable reference to the client configuration.
4191    pub fn config_mut(&mut self) -> &mut ::connectrpc::client::ClientConfig {
4192        &mut self.config
4193    }
4194    /// Call the Prune RPC. Sends a request to /store.compact.v1.Service/Prune.
4195    pub async fn prune(
4196        &self,
4197        request: PruneRequest,
4198    ) -> Result<
4199        ::connectrpc::client::UnaryResponse<
4200            ::buffa::view::OwnedView<PruneResponseView<'static>>,
4201        >,
4202        ::connectrpc::ConnectError,
4203    > {
4204        self.prune_with_options(request, ::connectrpc::client::CallOptions::default())
4205            .await
4206    }
4207    /// Call the Prune RPC with explicit per-call options. Options override [`connectrpc::client::ClientConfig`] defaults.
4208    pub async fn prune_with_options(
4209        &self,
4210        request: PruneRequest,
4211        options: ::connectrpc::client::CallOptions,
4212    ) -> Result<
4213        ::connectrpc::client::UnaryResponse<
4214            ::buffa::view::OwnedView<PruneResponseView<'static>>,
4215        >,
4216        ::connectrpc::ConnectError,
4217    > {
4218        ::connectrpc::client::call_unary(
4219                &self.transport,
4220                &self.config,
4221                SERVICE_SERVICE_NAME,
4222                "Prune",
4223                request,
4224                options,
4225            )
4226            .await
4227    }
4228}