Skip to main content

kacrab_protocol/generated/
read_share_group_state_summary_response.rs

1//! Generated from ReadShareGroupStateSummaryResponse.json - DO NOT EDIT
2#![allow(
3    missing_docs,
4    clippy::all,
5    clippy::pedantic,
6    clippy::nursery,
7    clippy::arithmetic_side_effects,
8    reason = "Generated protocol modules mirror Kafka's schema shape and intentionally trade \
9              hand-written lint style for reproducible wire-code output."
10)]
11use bytes::{Bytes, BytesMut};
12
13use crate::*;
14
15#[derive(Debug, Clone, PartialEq)]
16pub struct ReadShareGroupStateSummaryResponseData {
17    /// The read results.
18    pub results: Vec<ReadStateSummaryResult>,
19    pub _unknown_tagged_fields: Vec<RawTaggedField>,
20}
21impl Default for ReadShareGroupStateSummaryResponseData {
22    fn default() -> Self {
23        Self {
24            results: Vec::new(),
25            _unknown_tagged_fields: Vec::new(),
26        }
27    }
28}
29impl ReadShareGroupStateSummaryResponseData {
30    pub fn with_results(mut self, value: Vec<ReadStateSummaryResult>) -> Self {
31        self.results = value;
32        self
33    }
34    pub fn read(buf: &mut Bytes, version: i16) -> Result<Self> {
35        if version < 0 || version > 1 {
36            return Err(UnsupportedVersion::new(87, version).into());
37        }
38        let results;
39        let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
40        results = {
41            let len = read_compact_array_length(buf)?;
42            let mut arr = Vec::with_capacity(array_read_capacity(len, (buf).len()));
43            for _ in 0..len {
44                arr.push(ReadStateSummaryResult::read(buf, version)?);
45            }
46            arr
47        };
48        let tagged_fields = read_tagged_fields(buf)?;
49        for field in &tagged_fields {
50            match field.tag {
51                _ => {
52                    _unknown_tagged_fields.push(field.clone());
53                },
54            }
55        }
56        Ok(Self {
57            results,
58            _unknown_tagged_fields,
59        })
60    }
61    pub fn write(&self, buf: &mut BytesMut, version: i16) -> Result<()> {
62        if version < 0 || version > 1 {
63            return Err(UnsupportedVersion::new(87, version).into());
64        }
65        write_compact_array_length(buf, self.results.len() as i32);
66        for el in &self.results {
67            el.write(buf, version)?;
68        }
69        let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
70        all_tags.sort_by_key(|f| f.tag);
71        write_tagged_fields(buf, &all_tags)?;
72        Ok(())
73    }
74    pub fn encoded_len(&self, version: i16) -> Result<usize> {
75        if version < 0 || version > 1 {
76            return Err(UnsupportedVersion::new(87, version).into());
77        }
78        let mut len: usize = 0;
79        len += compact_array_length_len(self.results.len() as i32);
80        for el in &self.results {
81            len += el.encoded_len(version)?;
82        }
83        let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
84        all_tags.sort_by_key(|f| f.tag);
85        len += tagged_fields_len(&all_tags)?;
86        Ok(len)
87    }
88}
89#[derive(Debug, Clone, PartialEq)]
90pub struct ReadStateSummaryResult {
91    /// The topic identifier.
92    pub topic_id: KafkaUuid,
93    /// The results for the partitions.
94    pub partitions: Vec<PartitionResult>,
95    pub _unknown_tagged_fields: Vec<RawTaggedField>,
96}
97impl Default for ReadStateSummaryResult {
98    fn default() -> Self {
99        Self {
100            topic_id: KafkaUuid::ZERO,
101            partitions: Vec::new(),
102            _unknown_tagged_fields: Vec::new(),
103        }
104    }
105}
106impl ReadStateSummaryResult {
107    pub fn with_topic_id(mut self, value: KafkaUuid) -> Self {
108        self.topic_id = value;
109        self
110    }
111    pub fn with_partitions(mut self, value: Vec<PartitionResult>) -> Self {
112        self.partitions = value;
113        self
114    }
115    pub fn read(buf: &mut Bytes, version: i16) -> Result<Self> {
116        let topic_id;
117        let partitions;
118        let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
119        topic_id = read_uuid(buf)?;
120        partitions = {
121            let len = read_compact_array_length(buf)?;
122            let mut arr = Vec::with_capacity(array_read_capacity(len, (buf).len()));
123            for _ in 0..len {
124                arr.push(PartitionResult::read(buf, version)?);
125            }
126            arr
127        };
128        let tagged_fields = read_tagged_fields(buf)?;
129        for field in &tagged_fields {
130            match field.tag {
131                _ => {
132                    _unknown_tagged_fields.push(field.clone());
133                },
134            }
135        }
136        Ok(Self {
137            topic_id,
138            partitions,
139            _unknown_tagged_fields,
140        })
141    }
142    pub fn write(&self, buf: &mut BytesMut, version: i16) -> Result<()> {
143        write_uuid(buf, &self.topic_id);
144        write_compact_array_length(buf, self.partitions.len() as i32);
145        for el in &self.partitions {
146            el.write(buf, version)?;
147        }
148        let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
149        all_tags.sort_by_key(|f| f.tag);
150        write_tagged_fields(buf, &all_tags)?;
151        Ok(())
152    }
153    pub fn encoded_len(&self, version: i16) -> Result<usize> {
154        let mut len: usize = 0;
155        len += 16;
156        len += compact_array_length_len(self.partitions.len() as i32);
157        for el in &self.partitions {
158            len += el.encoded_len(version)?;
159        }
160        let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
161        all_tags.sort_by_key(|f| f.tag);
162        len += tagged_fields_len(&all_tags)?;
163        Ok(len)
164    }
165}
166#[derive(Debug, Clone, PartialEq)]
167pub struct PartitionResult {
168    /// The partition index.
169    pub partition: i32,
170    /// The error code, or 0 if there was no error.
171    pub error_code: i16,
172    /// The error message, or null if there was no error.
173    pub error_message: Option<KafkaString>,
174    /// The state epoch of the share-partition.
175    pub state_epoch: i32,
176    /// The leader epoch of the share-partition.
177    pub leader_epoch: i32,
178    /// The share-partition start offset.
179    pub start_offset: i64,
180    /// The number of offsets greater than or equal to share-partition start offset for which
181    /// delivery has been completed.
182    pub delivery_complete_count: i32,
183    pub _unknown_tagged_fields: Vec<RawTaggedField>,
184}
185impl Default for PartitionResult {
186    fn default() -> Self {
187        Self {
188            partition: 0_i32,
189            error_code: 0_i16,
190            error_message: None,
191            state_epoch: 0_i32,
192            leader_epoch: 0_i32,
193            start_offset: 0_i64,
194            delivery_complete_count: -1i32,
195            _unknown_tagged_fields: Vec::new(),
196        }
197    }
198}
199impl PartitionResult {
200    pub fn with_partition(mut self, value: i32) -> Self {
201        self.partition = value;
202        self
203    }
204    pub fn with_error_code(mut self, value: i16) -> Self {
205        self.error_code = value;
206        self
207    }
208    pub fn with_error_message(mut self, value: Option<KafkaString>) -> Self {
209        self.error_message = value;
210        self
211    }
212    pub fn with_state_epoch(mut self, value: i32) -> Self {
213        self.state_epoch = value;
214        self
215    }
216    pub fn with_leader_epoch(mut self, value: i32) -> Self {
217        self.leader_epoch = value;
218        self
219    }
220    pub fn with_start_offset(mut self, value: i64) -> Self {
221        self.start_offset = value;
222        self
223    }
224    pub fn with_delivery_complete_count(mut self, value: i32) -> Self {
225        self.delivery_complete_count = value;
226        self
227    }
228    pub fn read(buf: &mut Bytes, version: i16) -> Result<Self> {
229        let partition;
230        let error_code;
231        let error_message;
232        let state_epoch;
233        let leader_epoch;
234        let start_offset;
235        let mut delivery_complete_count = -1i32;
236        let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
237        partition = read_i32(buf)?;
238        error_code = read_i16(buf)?;
239        error_message = read_compact_nullable_string(buf)?;
240        state_epoch = read_i32(buf)?;
241        leader_epoch = read_i32(buf)?;
242        start_offset = read_i64(buf)?;
243        if version >= 1 {
244            delivery_complete_count = read_i32(buf)?;
245        }
246        let tagged_fields = read_tagged_fields(buf)?;
247        for field in &tagged_fields {
248            match field.tag {
249                _ => {
250                    _unknown_tagged_fields.push(field.clone());
251                },
252            }
253        }
254        Ok(Self {
255            partition,
256            error_code,
257            error_message,
258            state_epoch,
259            leader_epoch,
260            start_offset,
261            delivery_complete_count,
262            _unknown_tagged_fields,
263        })
264    }
265    pub fn write(&self, buf: &mut BytesMut, version: i16) -> Result<()> {
266        write_i32(buf, self.partition);
267        write_i16(buf, self.error_code);
268        write_compact_nullable_string(buf, self.error_message.as_ref())?;
269        write_i32(buf, self.state_epoch);
270        write_i32(buf, self.leader_epoch);
271        write_i64(buf, self.start_offset);
272        if version >= 1 {
273            write_i32(buf, self.delivery_complete_count);
274        } else if self.delivery_complete_count != -1i32 {
275            return Err(
276                UnsupportedFieldVersion::new(87, "delivery_complete_count", version).into(),
277            );
278        }
279        let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
280        all_tags.sort_by_key(|f| f.tag);
281        write_tagged_fields(buf, &all_tags)?;
282        Ok(())
283    }
284    pub fn encoded_len(&self, version: i16) -> Result<usize> {
285        let mut len: usize = 0;
286        len += 4;
287        len += 2;
288        len += compact_nullable_string_len(self.error_message.as_ref())?;
289        len += 4;
290        len += 4;
291        len += 8;
292        if version >= 1 {
293            len += 4;
294        } else if self.delivery_complete_count != -1i32 {
295            return Err(
296                UnsupportedFieldVersion::new(87, "delivery_complete_count", version).into(),
297            );
298        }
299        let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
300        all_tags.sort_by_key(|f| f.tag);
301        len += tagged_fields_len(&all_tags)?;
302        Ok(len)
303    }
304}