Skip to main content

kacrab_protocol/generated/
describe_share_group_offsets_request.rs

1//! Generated from DescribeShareGroupOffsetsRequest.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 DescribeShareGroupOffsetsRequestData {
17    /// The groups to describe offsets for.
18    pub groups: Vec<DescribeShareGroupOffsetsRequestGroup>,
19    pub _unknown_tagged_fields: Vec<RawTaggedField>,
20}
21impl Default for DescribeShareGroupOffsetsRequestData {
22    fn default() -> Self {
23        Self {
24            groups: Vec::new(),
25            _unknown_tagged_fields: Vec::new(),
26        }
27    }
28}
29impl DescribeShareGroupOffsetsRequestData {
30    pub fn with_groups(mut self, value: Vec<DescribeShareGroupOffsetsRequestGroup>) -> Self {
31        self.groups = 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(90, version).into());
37        }
38        let groups;
39        let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
40        groups = {
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(DescribeShareGroupOffsetsRequestGroup::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            groups,
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(90, version).into());
64        }
65        write_compact_array_length(buf, self.groups.len() as i32);
66        for el in &self.groups {
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(90, version).into());
77        }
78        let mut len: usize = 0;
79        len += compact_array_length_len(self.groups.len() as i32);
80        for el in &self.groups {
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 DescribeShareGroupOffsetsRequestGroup {
91    /// The group identifier.
92    pub group_id: KafkaString,
93    /// The topics to describe offsets for, or null for all topic-partitions.
94    pub topics: Option<Vec<DescribeShareGroupOffsetsRequestTopic>>,
95    pub _unknown_tagged_fields: Vec<RawTaggedField>,
96}
97impl Default for DescribeShareGroupOffsetsRequestGroup {
98    fn default() -> Self {
99        Self {
100            group_id: KafkaString::default(),
101            topics: None,
102            _unknown_tagged_fields: Vec::new(),
103        }
104    }
105}
106impl DescribeShareGroupOffsetsRequestGroup {
107    pub fn with_group_id(mut self, value: KafkaString) -> Self {
108        self.group_id = value;
109        self
110    }
111    pub fn with_topics(
112        mut self,
113        value: Option<Vec<DescribeShareGroupOffsetsRequestTopic>>,
114    ) -> Self {
115        self.topics = value;
116        self
117    }
118    pub fn read(buf: &mut Bytes, version: i16) -> Result<Self> {
119        let group_id;
120        let topics;
121        let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
122        group_id = read_compact_string(buf)?;
123        topics = {
124            let len = read_compact_array_length(buf)?;
125            if len < 0 {
126                None
127            } else {
128                let mut arr = Vec::with_capacity(array_read_capacity(len, (buf).len()));
129                for _ in 0..len {
130                    arr.push(DescribeShareGroupOffsetsRequestTopic::read(buf, version)?);
131                }
132                Some(arr)
133            }
134        };
135        let tagged_fields = read_tagged_fields(buf)?;
136        for field in &tagged_fields {
137            match field.tag {
138                _ => {
139                    _unknown_tagged_fields.push(field.clone());
140                },
141            }
142        }
143        Ok(Self {
144            group_id,
145            topics,
146            _unknown_tagged_fields,
147        })
148    }
149    pub fn write(&self, buf: &mut BytesMut, version: i16) -> Result<()> {
150        write_compact_string(buf, &self.group_id)?;
151        match &self.topics {
152            None => {
153                write_compact_array_length(buf, -1);
154            },
155            Some(arr) => {
156                write_compact_array_length(buf, arr.len() as i32);
157                for el in arr {
158                    el.write(buf, version)?;
159                }
160            },
161        }
162        let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
163        all_tags.sort_by_key(|f| f.tag);
164        write_tagged_fields(buf, &all_tags)?;
165        Ok(())
166    }
167    pub fn encoded_len(&self, version: i16) -> Result<usize> {
168        let mut len: usize = 0;
169        len += compact_string_len(&self.group_id)?;
170        match &self.topics {
171            None => {
172                len += compact_array_length_len(-1);
173            },
174            Some(arr) => {
175                len += compact_array_length_len(arr.len() as i32);
176                for el in arr {
177                    len += el.encoded_len(version)?;
178                }
179            },
180        }
181        let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
182        all_tags.sort_by_key(|f| f.tag);
183        len += tagged_fields_len(&all_tags)?;
184        Ok(len)
185    }
186}
187#[derive(Debug, Clone, PartialEq)]
188pub struct DescribeShareGroupOffsetsRequestTopic {
189    /// The topic name.
190    pub topic_name: KafkaString,
191    /// The partitions.
192    pub partitions: Vec<i32>,
193    pub _unknown_tagged_fields: Vec<RawTaggedField>,
194}
195impl Default for DescribeShareGroupOffsetsRequestTopic {
196    fn default() -> Self {
197        Self {
198            topic_name: KafkaString::default(),
199            partitions: Vec::new(),
200            _unknown_tagged_fields: Vec::new(),
201        }
202    }
203}
204impl DescribeShareGroupOffsetsRequestTopic {
205    pub fn with_topic_name(mut self, value: KafkaString) -> Self {
206        self.topic_name = value;
207        self
208    }
209    pub fn with_partitions(mut self, value: Vec<i32>) -> Self {
210        self.partitions = value;
211        self
212    }
213    pub fn read(buf: &mut Bytes, _version: i16) -> Result<Self> {
214        let topic_name;
215        let partitions;
216        let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
217        topic_name = read_compact_string(buf)?;
218        partitions = {
219            let len = read_compact_array_length(buf)?;
220            let mut arr = Vec::with_capacity(array_read_capacity(len, (buf).len()));
221            for _ in 0..len {
222                arr.push(read_i32(buf)?);
223            }
224            arr
225        };
226        let tagged_fields = read_tagged_fields(buf)?;
227        for field in &tagged_fields {
228            match field.tag {
229                _ => {
230                    _unknown_tagged_fields.push(field.clone());
231                },
232            }
233        }
234        Ok(Self {
235            topic_name,
236            partitions,
237            _unknown_tagged_fields,
238        })
239    }
240    pub fn write(&self, buf: &mut BytesMut, _version: i16) -> Result<()> {
241        write_compact_string(buf, &self.topic_name)?;
242        write_compact_array_length(buf, self.partitions.len() as i32);
243        for el in &self.partitions {
244            write_i32(buf, *el);
245        }
246        let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
247        all_tags.sort_by_key(|f| f.tag);
248        write_tagged_fields(buf, &all_tags)?;
249        Ok(())
250    }
251    pub fn encoded_len(&self, _version: i16) -> Result<usize> {
252        let mut len: usize = 0;
253        len += compact_string_len(&self.topic_name)?;
254        len += compact_array_length_len(self.partitions.len() as i32);
255        len += self.partitions.len() * 4usize;
256        let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
257        all_tags.sort_by_key(|f| f.tag);
258        len += tagged_fields_len(&all_tags)?;
259        Ok(len)
260    }
261}