Skip to main content

krabka_protocol/opt/rustwide/workdir/generated/
ShareFetchRequest.borrowed.rs

1// AUTO-GENERATED by krabka-protocol-codegen against a9ce3221537b8653448750697915607dc7936cf3. Do not edit.
2use bytes::BufMut;
3
4use crate::{
5    DecodeBorrow, Encode, ProtocolError, UnknownTaggedFields,
6    owned::share_fetch_request,
7    primitives::{
8        array::{array_len_prefix_len, get_array_len, put_array_len},
9        fixed::{get_bool, get_i8, get_i32, get_i64, put_bool, put_i8, put_i32, put_i64},
10        string_bytes::{
11            compact_nullable_string_len, nullable_string_len, put_compact_nullable_string,
12            put_nullable_string,
13        },
14        string_bytes_borrowed::{
15            get_compact_nullable_string_borrowed, get_nullable_string_borrowed,
16        },
17        uuid::{Uuid, get_uuid, put_uuid},
18    },
19    tagged_fields::{WriteTaggedFields, read_tagged_fields, tagged_fields_len},
20};
21pub const API_KEY: i16 = 78;
22pub const MIN_VERSION: i16 = 1;
23pub const MAX_VERSION: i16 = 2;
24pub const LATEST_STABLE_VERSION: i16 = 2;
25pub const FLEXIBLE_MIN: i16 = 0;
26#[inline]
27#[must_use]
28pub fn is_flexible(version: i16) -> bool {
29    version >= FLEXIBLE_MIN
30}
31#[derive(Debug, Clone, PartialEq, Eq)]
32pub struct ShareFetchRequest<'a> {
33    pub group_id: Option<&'a str>,
34    pub member_id: Option<&'a str>,
35    pub share_session_epoch: i32,
36    pub max_wait_ms: i32,
37    pub min_bytes: i32,
38    pub max_bytes: i32,
39    pub max_records: i32,
40    pub batch_size: i32,
41    pub share_acquire_mode: i8,
42    pub is_renew_ack: bool,
43    pub topics: Vec<FetchTopic>,
44    pub forgotten_topics_data: Vec<ForgottenTopic>,
45    pub unknown_tagged_fields: UnknownTaggedFields,
46}
47impl Default for ShareFetchRequest<'_> {
48    fn default() -> Self {
49        Self {
50            group_id: None,
51            member_id: Some(""),
52            share_session_epoch: 0i32,
53            max_wait_ms: 0i32,
54            min_bytes: 0i32,
55            max_bytes: 2_147_483_647i32,
56            max_records: 0i32,
57            batch_size: 0i32,
58            share_acquire_mode: 0i8,
59            is_renew_ack: false,
60            topics: Vec::new(),
61            forgotten_topics_data: Vec::new(),
62            unknown_tagged_fields: UnknownTaggedFields::default(),
63        }
64    }
65}
66impl<'a> ShareFetchRequest<'a> {
67    #[must_use]
68    pub fn to_owned(&self) -> share_fetch_request::ShareFetchRequest {
69        share_fetch_request::ShareFetchRequest {
70            group_id: (self.group_id).map(str::to_owned),
71            member_id: (self.member_id).map(str::to_owned),
72            share_session_epoch: (self.share_session_epoch),
73            max_wait_ms: (self.max_wait_ms),
74            min_bytes: (self.min_bytes),
75            max_bytes: (self.max_bytes),
76            max_records: (self.max_records),
77            batch_size: (self.batch_size),
78            share_acquire_mode: (self.share_acquire_mode),
79            is_renew_ack: (self.is_renew_ack),
80            topics: (self.topics).iter().map(FetchTopic::to_owned).collect(),
81            forgotten_topics_data: (self.forgotten_topics_data)
82                .iter()
83                .map(ForgottenTopic::to_owned)
84                .collect(),
85            unknown_tagged_fields: self.unknown_tagged_fields.clone(),
86        }
87    }
88    fn encode_field_0<B: BufMut>(
89        &self,
90        buf: &mut B,
91        version: i16,
92        flex: bool,
93    ) -> Result<(), ProtocolError> {
94        if version >= 0 {
95            if flex {
96                put_compact_nullable_string(buf, self.group_id)?;
97            } else {
98                put_nullable_string(buf, self.group_id)?;
99            }
100        }
101        Ok(())
102    }
103    fn encode_field_1<B: BufMut>(
104        &self,
105        buf: &mut B,
106        version: i16,
107        flex: bool,
108    ) -> Result<(), ProtocolError> {
109        if version >= 0 {
110            if flex {
111                put_compact_nullable_string(buf, self.member_id)?;
112            } else {
113                put_nullable_string(buf, self.member_id)?;
114            }
115        }
116        Ok(())
117    }
118    fn encode_field_2<B: BufMut>(&self, buf: &mut B, version: i16, _flex: bool) {
119        if version >= 0 {
120            put_i32(buf, self.share_session_epoch);
121        }
122    }
123    fn encode_field_3<B: BufMut>(&self, buf: &mut B, version: i16, _flex: bool) {
124        if version >= 0 {
125            put_i32(buf, self.max_wait_ms);
126        }
127    }
128    fn encode_field_4<B: BufMut>(&self, buf: &mut B, version: i16, _flex: bool) {
129        if version >= 0 {
130            put_i32(buf, self.min_bytes);
131        }
132    }
133    fn encode_field_5<B: BufMut>(&self, buf: &mut B, version: i16, _flex: bool) {
134        if version >= 0 {
135            put_i32(buf, self.max_bytes);
136        }
137    }
138    fn encode_field_6<B: BufMut>(&self, buf: &mut B, version: i16, _flex: bool) {
139        if version >= 1 {
140            put_i32(buf, self.max_records);
141        }
142    }
143    fn encode_field_7<B: BufMut>(&self, buf: &mut B, version: i16, _flex: bool) {
144        if version >= 1 {
145            put_i32(buf, self.batch_size);
146        }
147    }
148    fn encode_field_8<B: BufMut>(&self, buf: &mut B, version: i16, _flex: bool) {
149        if version >= 2 {
150            put_i8(buf, self.share_acquire_mode);
151        }
152    }
153    fn encode_field_9<B: BufMut>(&self, buf: &mut B, version: i16, _flex: bool) {
154        if version >= 2 {
155            put_bool(buf, self.is_renew_ack);
156        }
157    }
158    fn encode_field_10<B: BufMut>(
159        &self,
160        buf: &mut B,
161        version: i16,
162        flex: bool,
163    ) -> Result<(), ProtocolError> {
164        if version >= 0 {
165            {
166                put_array_len(buf, (self.topics).len(), flex)?;
167                for it in &self.topics {
168                    it.encode(buf, version)?;
169                }
170            }
171        }
172        Ok(())
173    }
174    fn encode_field_11<B: BufMut>(
175        &self,
176        buf: &mut B,
177        version: i16,
178        flex: bool,
179    ) -> Result<(), ProtocolError> {
180        if version >= 0 {
181            {
182                put_array_len(buf, (self.forgotten_topics_data).len(), flex)?;
183                for it in &self.forgotten_topics_data {
184                    it.encode(buf, version)?;
185                }
186            }
187        }
188        Ok(())
189    }
190    fn encode_tagged_fields<B: BufMut>(
191        &self,
192        buf: &mut B,
193        _version: i16,
194        flex: bool,
195    ) -> Result<(), ProtocolError> {
196        if flex {
197            let tagged = WriteTaggedFields::new();
198            tagged.write(buf, &self.unknown_tagged_fields)?;
199        }
200        Ok(())
201    }
202    fn decode_field_0(
203        out: &mut Self,
204        buf: &mut &'a [u8],
205        version: i16,
206        flex: bool,
207    ) -> Result<(), ProtocolError> {
208        if version >= 0 {
209            out.group_id = if flex {
210                get_compact_nullable_string_borrowed(buf)?
211            } else {
212                get_nullable_string_borrowed(buf)?
213            };
214        }
215        Ok(())
216    }
217    fn decode_field_1(
218        out: &mut Self,
219        buf: &mut &'a [u8],
220        version: i16,
221        flex: bool,
222    ) -> Result<(), ProtocolError> {
223        if version >= 0 {
224            out.member_id = if flex {
225                get_compact_nullable_string_borrowed(buf)?
226            } else {
227                get_nullable_string_borrowed(buf)?
228            };
229        }
230        Ok(())
231    }
232    fn decode_field_2(
233        out: &mut Self,
234        buf: &mut &'a [u8],
235        version: i16,
236        _flex: bool,
237    ) -> Result<(), ProtocolError> {
238        if version >= 0 {
239            out.share_session_epoch = get_i32(buf)?;
240        }
241        Ok(())
242    }
243    fn decode_field_3(
244        out: &mut Self,
245        buf: &mut &'a [u8],
246        version: i16,
247        _flex: bool,
248    ) -> Result<(), ProtocolError> {
249        if version >= 0 {
250            out.max_wait_ms = get_i32(buf)?;
251        }
252        Ok(())
253    }
254    fn decode_field_4(
255        out: &mut Self,
256        buf: &mut &'a [u8],
257        version: i16,
258        _flex: bool,
259    ) -> Result<(), ProtocolError> {
260        if version >= 0 {
261            out.min_bytes = get_i32(buf)?;
262        }
263        Ok(())
264    }
265    fn decode_field_5(
266        out: &mut Self,
267        buf: &mut &'a [u8],
268        version: i16,
269        _flex: bool,
270    ) -> Result<(), ProtocolError> {
271        if version >= 0 {
272            out.max_bytes = get_i32(buf)?;
273        }
274        Ok(())
275    }
276    fn decode_field_6(
277        out: &mut Self,
278        buf: &mut &'a [u8],
279        version: i16,
280        _flex: bool,
281    ) -> Result<(), ProtocolError> {
282        if version >= 1 {
283            out.max_records = get_i32(buf)?;
284        }
285        Ok(())
286    }
287    fn decode_field_7(
288        out: &mut Self,
289        buf: &mut &'a [u8],
290        version: i16,
291        _flex: bool,
292    ) -> Result<(), ProtocolError> {
293        if version >= 1 {
294            out.batch_size = get_i32(buf)?;
295        }
296        Ok(())
297    }
298    fn decode_field_8(
299        out: &mut Self,
300        buf: &mut &'a [u8],
301        version: i16,
302        _flex: bool,
303    ) -> Result<(), ProtocolError> {
304        if version >= 2 {
305            out.share_acquire_mode = get_i8(buf)?;
306        }
307        Ok(())
308    }
309    fn decode_field_9(
310        out: &mut Self,
311        buf: &mut &'a [u8],
312        version: i16,
313        _flex: bool,
314    ) -> Result<(), ProtocolError> {
315        if version >= 2 {
316            out.is_renew_ack = get_bool(buf)?;
317        }
318        Ok(())
319    }
320    fn decode_field_10(
321        out: &mut Self,
322        buf: &mut &'a [u8],
323        version: i16,
324        flex: bool,
325    ) -> Result<(), ProtocolError> {
326        if version >= 0 {
327            out.topics = {
328                let n = get_array_len(buf, flex)?;
329                let mut v = Vec::with_capacity(n);
330                for _ in 0..n {
331                    v.push(FetchTopic::decode_borrow(buf, version)?);
332                }
333                v
334            };
335        }
336        Ok(())
337    }
338    fn decode_field_11(
339        out: &mut Self,
340        buf: &mut &'a [u8],
341        version: i16,
342        flex: bool,
343    ) -> Result<(), ProtocolError> {
344        if version >= 0 {
345            out.forgotten_topics_data = {
346                let n = get_array_len(buf, flex)?;
347                let mut v = Vec::with_capacity(n);
348                for _ in 0..n {
349                    v.push(ForgottenTopic::decode_borrow(buf, version)?);
350                }
351                v
352            };
353        }
354        Ok(())
355    }
356    fn decode_tagged_fields(
357        out: &mut Self,
358        buf: &mut &'a [u8],
359        _version: i16,
360        flex: bool,
361    ) -> Result<(), ProtocolError> {
362        if flex {
363            out.unknown_tagged_fields = read_tagged_fields(buf, |_tag, _payload| Ok(false))?;
364        }
365        Ok(())
366    }
367}
368impl Encode for ShareFetchRequest<'_> {
369    fn encode<B: BufMut>(&self, buf: &mut B, version: i16) -> Result<(), ProtocolError> {
370        if !(MIN_VERSION..=MAX_VERSION).contains(&version) {
371            return Err(ProtocolError::UnsupportedVersion {
372                api_key: API_KEY,
373                version,
374            });
375        }
376        let flex = is_flexible(version);
377        self.encode_field_0(buf, version, flex)?;
378        self.encode_field_1(buf, version, flex)?;
379        self.encode_field_2(buf, version, flex);
380        self.encode_field_3(buf, version, flex);
381        self.encode_field_4(buf, version, flex);
382        self.encode_field_5(buf, version, flex);
383        self.encode_field_6(buf, version, flex);
384        self.encode_field_7(buf, version, flex);
385        self.encode_field_8(buf, version, flex);
386        self.encode_field_9(buf, version, flex);
387        self.encode_field_10(buf, version, flex)?;
388        self.encode_field_11(buf, version, flex)?;
389        self.encode_tagged_fields(buf, version, flex)?;
390        Ok(())
391    }
392    fn encoded_len(&self, version: i16) -> usize {
393        let flex = is_flexible(version);
394        let mut n: usize = 0;
395        if version >= 0 {
396            n += if flex {
397                compact_nullable_string_len(self.group_id)
398            } else {
399                nullable_string_len(self.group_id)
400            };
401        }
402        if version >= 0 {
403            n += if flex {
404                compact_nullable_string_len(self.member_id)
405            } else {
406                nullable_string_len(self.member_id)
407            };
408        }
409        if version >= 0 {
410            n += 4;
411        }
412        if version >= 0 {
413            n += 4;
414        }
415        if version >= 0 {
416            n += 4;
417        }
418        if version >= 0 {
419            n += 4;
420        }
421        if version >= 1 {
422            n += 4;
423        }
424        if version >= 1 {
425            n += 4;
426        }
427        if version >= 2 {
428            n += 1;
429        }
430        if version >= 2 {
431            n += 1;
432        }
433        if version >= 0 {
434            n += {
435                let prefix = array_len_prefix_len((self.topics).len(), flex);
436                let body: usize = (self.topics).iter().map(|it| it.encoded_len(version)).sum();
437                prefix + body
438            };
439        }
440        if version >= 0 {
441            n += {
442                let prefix = array_len_prefix_len((self.forgotten_topics_data).len(), flex);
443                let body: usize = (self.forgotten_topics_data)
444                    .iter()
445                    .map(|it| it.encoded_len(version))
446                    .sum();
447                prefix + body
448            };
449        }
450        if flex {
451            let known_pairs: Vec<(u32, usize)> = Vec::new();
452            n += tagged_fields_len(&known_pairs, &self.unknown_tagged_fields);
453        }
454        n
455    }
456}
457impl<'de> DecodeBorrow<'de> for ShareFetchRequest<'de> {
458    fn decode_borrow(buf: &mut &'de [u8], version: i16) -> Result<Self, ProtocolError> {
459        if !(MIN_VERSION..=MAX_VERSION).contains(&version) {
460            return Err(ProtocolError::UnsupportedVersion {
461                api_key: API_KEY,
462                version,
463            });
464        }
465        let flex = is_flexible(version);
466        let mut out = Self::default();
467        Self::decode_field_0(&mut out, buf, version, flex)?;
468        Self::decode_field_1(&mut out, buf, version, flex)?;
469        Self::decode_field_2(&mut out, buf, version, flex)?;
470        Self::decode_field_3(&mut out, buf, version, flex)?;
471        Self::decode_field_4(&mut out, buf, version, flex)?;
472        Self::decode_field_5(&mut out, buf, version, flex)?;
473        Self::decode_field_6(&mut out, buf, version, flex)?;
474        Self::decode_field_7(&mut out, buf, version, flex)?;
475        Self::decode_field_8(&mut out, buf, version, flex)?;
476        Self::decode_field_9(&mut out, buf, version, flex)?;
477        Self::decode_field_10(&mut out, buf, version, flex)?;
478        Self::decode_field_11(&mut out, buf, version, flex)?;
479        Self::decode_tagged_fields(&mut out, buf, version, flex)?;
480        Ok(out)
481    }
482}
483#[cfg(test)]
484impl ShareFetchRequest<'_> {
485    #[must_use]
486    pub fn populated(version: i16) -> Self {
487        let mut m = Self::default();
488        if version >= 0 {
489            m.group_id = Some("x");
490        }
491        if version >= 0 {
492            m.member_id = Some("x");
493        }
494        if version >= 0 {
495            m.share_session_epoch = 1i32;
496        }
497        if version >= 0 {
498            m.max_wait_ms = 1i32;
499        }
500        if version >= 0 {
501            m.min_bytes = 1i32;
502        }
503        if version >= 0 {
504            m.max_bytes = 1i32;
505        }
506        if version >= 1 {
507            m.max_records = 1i32;
508        }
509        if version >= 1 {
510            m.batch_size = 1i32;
511        }
512        if version >= 2 {
513            m.share_acquire_mode = 1i8;
514        }
515        if version >= 2 {
516            m.is_renew_ack = true;
517        }
518        if version >= 0 {
519            m.topics = vec![FetchTopic::populated(version)];
520        }
521        if version >= 0 {
522            m.forgotten_topics_data = vec![ForgottenTopic::populated(version)];
523        }
524        m
525    }
526}
527#[derive(Debug, Clone, PartialEq, Eq, Default)]
528pub struct FetchTopic {
529    pub topic_id: Uuid,
530    pub partitions: Vec<FetchPartition>,
531    pub unknown_tagged_fields: UnknownTaggedFields,
532}
533impl FetchTopic {
534    #[must_use]
535    pub fn to_owned(&self) -> share_fetch_request::FetchTopic {
536        share_fetch_request::FetchTopic {
537            topic_id: (self.topic_id),
538            partitions: (self.partitions)
539                .iter()
540                .map(FetchPartition::to_owned)
541                .collect(),
542            unknown_tagged_fields: self.unknown_tagged_fields.clone(),
543        }
544    }
545}
546impl Encode for FetchTopic {
547    fn encode<B: BufMut>(&self, buf: &mut B, version: i16) -> Result<(), ProtocolError> {
548        let flex = version >= 0;
549        if version >= 0 {
550            put_uuid(buf, self.topic_id);
551        }
552        if version >= 0 {
553            {
554                put_array_len(buf, (self.partitions).len(), flex)?;
555                for it in &self.partitions {
556                    it.encode(buf, version)?;
557                }
558            }
559        }
560        if flex {
561            let tagged = WriteTaggedFields::new();
562            tagged.write(buf, &self.unknown_tagged_fields)?;
563        }
564        Ok(())
565    }
566    fn encoded_len(&self, version: i16) -> usize {
567        let flex = version >= 0;
568        let mut n: usize = 0;
569        if version >= 0 {
570            n += 16;
571        }
572        if version >= 0 {
573            n += {
574                let prefix = array_len_prefix_len((self.partitions).len(), flex);
575                let body: usize = (self.partitions)
576                    .iter()
577                    .map(|it| it.encoded_len(version))
578                    .sum();
579                prefix + body
580            };
581        }
582        if flex {
583            let known_pairs: Vec<(u32, usize)> = Vec::new();
584            n += tagged_fields_len(&known_pairs, &self.unknown_tagged_fields);
585        }
586        n
587    }
588}
589impl<'de> DecodeBorrow<'de> for FetchTopic {
590    fn decode_borrow(buf: &mut &'de [u8], version: i16) -> Result<Self, ProtocolError> {
591        let flex = version >= 0;
592        let mut out = Self::default();
593        if version >= 0 {
594            out.topic_id = get_uuid(buf)?;
595        }
596        if version >= 0 {
597            out.partitions = {
598                let n = get_array_len(buf, flex)?;
599                let mut v = Vec::with_capacity(n);
600                for _ in 0..n {
601                    v.push(FetchPartition::decode_borrow(buf, version)?);
602                }
603                v
604            };
605        }
606        if flex {
607            out.unknown_tagged_fields = read_tagged_fields(buf, |_tag, _payload| Ok(false))?;
608        }
609        Ok(out)
610    }
611}
612#[cfg(test)]
613impl FetchTopic {
614    #[must_use]
615    pub fn populated(version: i16) -> Self {
616        let mut m = Self::default();
617        if version >= 0 {
618            m.topic_id = Uuid([1u8; 16]);
619        }
620        if version >= 0 {
621            m.partitions = vec![FetchPartition::populated(version)];
622        }
623        m
624    }
625}
626#[derive(Debug, Clone, PartialEq, Eq, Default)]
627pub struct FetchPartition {
628    pub partition_index: i32,
629    pub partition_max_bytes: i32,
630    pub acknowledgement_batches: Vec<AcknowledgementBatch>,
631    pub unknown_tagged_fields: UnknownTaggedFields,
632}
633impl FetchPartition {
634    #[must_use]
635    pub fn to_owned(&self) -> share_fetch_request::FetchPartition {
636        share_fetch_request::FetchPartition {
637            partition_index: (self.partition_index),
638            partition_max_bytes: (self.partition_max_bytes),
639            acknowledgement_batches: (self.acknowledgement_batches)
640                .iter()
641                .map(AcknowledgementBatch::to_owned)
642                .collect(),
643            unknown_tagged_fields: self.unknown_tagged_fields.clone(),
644        }
645    }
646}
647impl Encode for FetchPartition {
648    fn encode<B: BufMut>(&self, buf: &mut B, version: i16) -> Result<(), ProtocolError> {
649        let flex = version >= 0;
650        if version >= 0 {
651            put_i32(buf, self.partition_index);
652        }
653        if version == 0 {
654            put_i32(buf, self.partition_max_bytes);
655        }
656        if version >= 0 {
657            {
658                put_array_len(buf, (self.acknowledgement_batches).len(), flex)?;
659                for it in &self.acknowledgement_batches {
660                    it.encode(buf, version)?;
661                }
662            }
663        }
664        if flex {
665            let tagged = WriteTaggedFields::new();
666            tagged.write(buf, &self.unknown_tagged_fields)?;
667        }
668        Ok(())
669    }
670    fn encoded_len(&self, version: i16) -> usize {
671        let flex = version >= 0;
672        let mut n: usize = 0;
673        if version >= 0 {
674            n += 4;
675        }
676        if version == 0 {
677            n += 4;
678        }
679        if version >= 0 {
680            n += {
681                let prefix = array_len_prefix_len((self.acknowledgement_batches).len(), flex);
682                let body: usize = (self.acknowledgement_batches)
683                    .iter()
684                    .map(|it| it.encoded_len(version))
685                    .sum();
686                prefix + body
687            };
688        }
689        if flex {
690            let known_pairs: Vec<(u32, usize)> = Vec::new();
691            n += tagged_fields_len(&known_pairs, &self.unknown_tagged_fields);
692        }
693        n
694    }
695}
696impl<'de> DecodeBorrow<'de> for FetchPartition {
697    fn decode_borrow(buf: &mut &'de [u8], version: i16) -> Result<Self, ProtocolError> {
698        let flex = version >= 0;
699        let mut out = Self::default();
700        if version >= 0 {
701            out.partition_index = get_i32(buf)?;
702        }
703        if version == 0 {
704            out.partition_max_bytes = get_i32(buf)?;
705        }
706        if version >= 0 {
707            out.acknowledgement_batches = {
708                let n = get_array_len(buf, flex)?;
709                let mut v = Vec::with_capacity(n);
710                for _ in 0..n {
711                    v.push(AcknowledgementBatch::decode_borrow(buf, version)?);
712                }
713                v
714            };
715        }
716        if flex {
717            out.unknown_tagged_fields = read_tagged_fields(buf, |_tag, _payload| Ok(false))?;
718        }
719        Ok(out)
720    }
721}
722#[cfg(test)]
723impl FetchPartition {
724    #[must_use]
725    pub fn populated(version: i16) -> Self {
726        let mut m = Self::default();
727        if version >= 0 {
728            m.partition_index = 1i32;
729        }
730        if version == 0 {
731            m.partition_max_bytes = 1i32;
732        }
733        if version >= 0 {
734            m.acknowledgement_batches = vec![AcknowledgementBatch::populated(version)];
735        }
736        m
737    }
738}
739#[derive(Debug, Clone, PartialEq, Eq, Default)]
740pub struct AcknowledgementBatch {
741    pub first_offset: i64,
742    pub last_offset: i64,
743    pub acknowledge_types: Vec<i8>,
744    pub unknown_tagged_fields: UnknownTaggedFields,
745}
746impl AcknowledgementBatch {
747    #[must_use]
748    pub fn to_owned(&self) -> share_fetch_request::AcknowledgementBatch {
749        share_fetch_request::AcknowledgementBatch {
750            first_offset: (self.first_offset),
751            last_offset: (self.last_offset),
752            acknowledge_types: (self.acknowledge_types).clone(),
753            unknown_tagged_fields: self.unknown_tagged_fields.clone(),
754        }
755    }
756}
757impl Encode for AcknowledgementBatch {
758    fn encode<B: BufMut>(&self, buf: &mut B, version: i16) -> Result<(), ProtocolError> {
759        let flex = version >= 0;
760        if version >= 0 {
761            put_i64(buf, self.first_offset);
762        }
763        if version >= 0 {
764            put_i64(buf, self.last_offset);
765        }
766        if version >= 0 {
767            {
768                put_array_len(buf, (self.acknowledge_types).len(), flex)?;
769                for it in &self.acknowledge_types {
770                    put_i8(buf, *it);
771                }
772            }
773        }
774        if flex {
775            let tagged = WriteTaggedFields::new();
776            tagged.write(buf, &self.unknown_tagged_fields)?;
777        }
778        Ok(())
779    }
780    fn encoded_len(&self, version: i16) -> usize {
781        let flex = version >= 0;
782        let mut n: usize = 0;
783        if version >= 0 {
784            n += 8;
785        }
786        if version >= 0 {
787            n += 8;
788        }
789        if version >= 0 {
790            n += {
791                let prefix = array_len_prefix_len((self.acknowledge_types).len(), flex);
792                let body: usize = (self.acknowledge_types).iter().map(|_| 1).sum();
793                prefix + body
794            };
795        }
796        if flex {
797            let known_pairs: Vec<(u32, usize)> = Vec::new();
798            n += tagged_fields_len(&known_pairs, &self.unknown_tagged_fields);
799        }
800        n
801    }
802}
803impl<'de> DecodeBorrow<'de> for AcknowledgementBatch {
804    fn decode_borrow(buf: &mut &'de [u8], version: i16) -> Result<Self, ProtocolError> {
805        let flex = version >= 0;
806        let mut out = Self::default();
807        if version >= 0 {
808            out.first_offset = get_i64(buf)?;
809        }
810        if version >= 0 {
811            out.last_offset = get_i64(buf)?;
812        }
813        if version >= 0 {
814            out.acknowledge_types = {
815                let n = get_array_len(buf, flex)?;
816                let mut v = Vec::with_capacity(n);
817                for _ in 0..n {
818                    v.push(get_i8(buf)?);
819                }
820                v
821            };
822        }
823        if flex {
824            out.unknown_tagged_fields = read_tagged_fields(buf, |_tag, _payload| Ok(false))?;
825        }
826        Ok(out)
827    }
828}
829#[cfg(test)]
830impl AcknowledgementBatch {
831    #[must_use]
832    pub fn populated(version: i16) -> Self {
833        let mut m = Self::default();
834        if version >= 0 {
835            m.first_offset = 1i64;
836        }
837        if version >= 0 {
838            m.last_offset = 1i64;
839        }
840        if version >= 0 {
841            m.acknowledge_types = vec![1i8];
842        }
843        m
844    }
845}
846#[derive(Debug, Clone, PartialEq, Eq, Default)]
847pub struct ForgottenTopic {
848    pub topic_id: Uuid,
849    pub partitions: Vec<i32>,
850    pub unknown_tagged_fields: UnknownTaggedFields,
851}
852impl ForgottenTopic {
853    #[must_use]
854    pub fn to_owned(&self) -> share_fetch_request::ForgottenTopic {
855        share_fetch_request::ForgottenTopic {
856            topic_id: (self.topic_id),
857            partitions: (self.partitions).clone(),
858            unknown_tagged_fields: self.unknown_tagged_fields.clone(),
859        }
860    }
861}
862impl Encode for ForgottenTopic {
863    fn encode<B: BufMut>(&self, buf: &mut B, version: i16) -> Result<(), ProtocolError> {
864        let flex = version >= 0;
865        if version >= 0 {
866            put_uuid(buf, self.topic_id);
867        }
868        if version >= 0 {
869            {
870                put_array_len(buf, (self.partitions).len(), flex)?;
871                for it in &self.partitions {
872                    put_i32(buf, *it);
873                }
874            }
875        }
876        if flex {
877            let tagged = WriteTaggedFields::new();
878            tagged.write(buf, &self.unknown_tagged_fields)?;
879        }
880        Ok(())
881    }
882    fn encoded_len(&self, version: i16) -> usize {
883        let flex = version >= 0;
884        let mut n: usize = 0;
885        if version >= 0 {
886            n += 16;
887        }
888        if version >= 0 {
889            n += {
890                let prefix = array_len_prefix_len((self.partitions).len(), flex);
891                let body: usize = (self.partitions).iter().map(|_| 4).sum();
892                prefix + body
893            };
894        }
895        if flex {
896            let known_pairs: Vec<(u32, usize)> = Vec::new();
897            n += tagged_fields_len(&known_pairs, &self.unknown_tagged_fields);
898        }
899        n
900    }
901}
902impl<'de> DecodeBorrow<'de> for ForgottenTopic {
903    fn decode_borrow(buf: &mut &'de [u8], version: i16) -> Result<Self, ProtocolError> {
904        let flex = version >= 0;
905        let mut out = Self::default();
906        if version >= 0 {
907            out.topic_id = get_uuid(buf)?;
908        }
909        if version >= 0 {
910            out.partitions = {
911                let n = get_array_len(buf, flex)?;
912                let mut v = Vec::with_capacity(n);
913                for _ in 0..n {
914                    v.push(get_i32(buf)?);
915                }
916                v
917            };
918        }
919        if flex {
920            out.unknown_tagged_fields = read_tagged_fields(buf, |_tag, _payload| Ok(false))?;
921        }
922        Ok(out)
923    }
924}
925#[cfg(test)]
926impl ForgottenTopic {
927    #[must_use]
928    pub fn populated(version: i16) -> Self {
929        let mut m = Self::default();
930        if version >= 0 {
931            m.topic_id = Uuid([1u8; 16]);
932        }
933        if version >= 0 {
934            m.partitions = vec![1i32];
935        }
936        m
937    }
938}