Skip to main content

kacrab_protocol/generated/
alter_share_group_offsets_request.rs

1//! Generated from AlterShareGroupOffsetsRequest.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 AlterShareGroupOffsetsRequestData {
17    /// The group identifier.
18    pub group_id: KafkaString,
19    /// The topics to alter offsets for.
20    pub topics: Vec<AlterShareGroupOffsetsRequestTopic>,
21    pub _unknown_tagged_fields: Vec<RawTaggedField>,
22}
23impl Default for AlterShareGroupOffsetsRequestData {
24    fn default() -> Self {
25        Self {
26            group_id: KafkaString::default(),
27            topics: Vec::new(),
28            _unknown_tagged_fields: Vec::new(),
29        }
30    }
31}
32impl AlterShareGroupOffsetsRequestData {
33    pub fn with_group_id(mut self, value: KafkaString) -> Self {
34        self.group_id = value;
35        self
36    }
37    pub fn with_topics(mut self, value: Vec<AlterShareGroupOffsetsRequestTopic>) -> Self {
38        self.topics = value;
39        self
40    }
41    pub fn read(buf: &mut Bytes, version: i16) -> Result<Self> {
42        if version < 0 || version > 0 {
43            return Err(UnsupportedVersion::new(91, version).into());
44        }
45        let group_id;
46        let topics;
47        let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
48        group_id = read_compact_string(buf)?;
49        topics = {
50            let len = read_compact_array_length(buf)?;
51            let mut arr = Vec::with_capacity(array_read_capacity(len, (buf).len()));
52            for _ in 0..len {
53                arr.push(AlterShareGroupOffsetsRequestTopic::read(buf, version)?);
54            }
55            arr
56        };
57        let tagged_fields = read_tagged_fields(buf)?;
58        for field in &tagged_fields {
59            match field.tag {
60                _ => {
61                    _unknown_tagged_fields.push(field.clone());
62                },
63            }
64        }
65        Ok(Self {
66            group_id,
67            topics,
68            _unknown_tagged_fields,
69        })
70    }
71    pub fn write(&self, buf: &mut BytesMut, version: i16) -> Result<()> {
72        if version < 0 || version > 0 {
73            return Err(UnsupportedVersion::new(91, version).into());
74        }
75        write_compact_string(buf, &self.group_id)?;
76        write_compact_array_length(buf, self.topics.len() as i32);
77        for el in &self.topics {
78            el.write(buf, version)?;
79        }
80        let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
81        all_tags.sort_by_key(|f| f.tag);
82        write_tagged_fields(buf, &all_tags)?;
83        Ok(())
84    }
85    pub fn encoded_len(&self, version: i16) -> Result<usize> {
86        if version < 0 || version > 0 {
87            return Err(UnsupportedVersion::new(91, version).into());
88        }
89        let mut len: usize = 0;
90        len += compact_string_len(&self.group_id)?;
91        len += compact_array_length_len(self.topics.len() as i32);
92        for el in &self.topics {
93            len += el.encoded_len(version)?;
94        }
95        let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
96        all_tags.sort_by_key(|f| f.tag);
97        len += tagged_fields_len(&all_tags)?;
98        Ok(len)
99    }
100}
101#[derive(Debug, Clone, PartialEq)]
102pub struct AlterShareGroupOffsetsRequestTopic {
103    /// The topic name.
104    pub topic_name: KafkaString,
105    /// Each partition to alter offsets for.
106    pub partitions: Vec<AlterShareGroupOffsetsRequestPartition>,
107    pub _unknown_tagged_fields: Vec<RawTaggedField>,
108}
109impl Default for AlterShareGroupOffsetsRequestTopic {
110    fn default() -> Self {
111        Self {
112            topic_name: KafkaString::default(),
113            partitions: Vec::new(),
114            _unknown_tagged_fields: Vec::new(),
115        }
116    }
117}
118impl AlterShareGroupOffsetsRequestTopic {
119    pub fn with_topic_name(mut self, value: KafkaString) -> Self {
120        self.topic_name = value;
121        self
122    }
123    pub fn with_partitions(mut self, value: Vec<AlterShareGroupOffsetsRequestPartition>) -> Self {
124        self.partitions = value;
125        self
126    }
127    pub fn read(buf: &mut Bytes, version: i16) -> Result<Self> {
128        let topic_name;
129        let partitions;
130        let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
131        topic_name = read_compact_string(buf)?;
132        partitions = {
133            let len = read_compact_array_length(buf)?;
134            let mut arr = Vec::with_capacity(array_read_capacity(len, (buf).len()));
135            for _ in 0..len {
136                arr.push(AlterShareGroupOffsetsRequestPartition::read(buf, version)?);
137            }
138            arr
139        };
140        let tagged_fields = read_tagged_fields(buf)?;
141        for field in &tagged_fields {
142            match field.tag {
143                _ => {
144                    _unknown_tagged_fields.push(field.clone());
145                },
146            }
147        }
148        Ok(Self {
149            topic_name,
150            partitions,
151            _unknown_tagged_fields,
152        })
153    }
154    pub fn write(&self, buf: &mut BytesMut, version: i16) -> Result<()> {
155        write_compact_string(buf, &self.topic_name)?;
156        write_compact_array_length(buf, self.partitions.len() as i32);
157        for el in &self.partitions {
158            el.write(buf, version)?;
159        }
160        let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
161        all_tags.sort_by_key(|f| f.tag);
162        write_tagged_fields(buf, &all_tags)?;
163        Ok(())
164    }
165    pub fn encoded_len(&self, version: i16) -> Result<usize> {
166        let mut len: usize = 0;
167        len += compact_string_len(&self.topic_name)?;
168        len += compact_array_length_len(self.partitions.len() as i32);
169        for el in &self.partitions {
170            len += el.encoded_len(version)?;
171        }
172        let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
173        all_tags.sort_by_key(|f| f.tag);
174        len += tagged_fields_len(&all_tags)?;
175        Ok(len)
176    }
177}
178#[derive(Debug, Clone, PartialEq)]
179pub struct AlterShareGroupOffsetsRequestPartition {
180    /// The partition index.
181    pub partition_index: i32,
182    /// The share-partition start offset.
183    pub start_offset: i64,
184    pub _unknown_tagged_fields: Vec<RawTaggedField>,
185}
186impl Default for AlterShareGroupOffsetsRequestPartition {
187    fn default() -> Self {
188        Self {
189            partition_index: 0_i32,
190            start_offset: 0_i64,
191            _unknown_tagged_fields: Vec::new(),
192        }
193    }
194}
195impl AlterShareGroupOffsetsRequestPartition {
196    pub fn with_partition_index(mut self, value: i32) -> Self {
197        self.partition_index = value;
198        self
199    }
200    pub fn with_start_offset(mut self, value: i64) -> Self {
201        self.start_offset = value;
202        self
203    }
204    pub fn read(buf: &mut Bytes, _version: i16) -> Result<Self> {
205        let partition_index;
206        let start_offset;
207        let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
208        partition_index = read_i32(buf)?;
209        start_offset = read_i64(buf)?;
210        let tagged_fields = read_tagged_fields(buf)?;
211        for field in &tagged_fields {
212            match field.tag {
213                _ => {
214                    _unknown_tagged_fields.push(field.clone());
215                },
216            }
217        }
218        Ok(Self {
219            partition_index,
220            start_offset,
221            _unknown_tagged_fields,
222        })
223    }
224    pub fn write(&self, buf: &mut BytesMut, _version: i16) -> Result<()> {
225        write_i32(buf, self.partition_index);
226        write_i64(buf, self.start_offset);
227        let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
228        all_tags.sort_by_key(|f| f.tag);
229        write_tagged_fields(buf, &all_tags)?;
230        Ok(())
231    }
232    pub fn encoded_len(&self, _version: i16) -> Result<usize> {
233        let mut len: usize = 0;
234        len += 4;
235        len += 8;
236        let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
237        all_tags.sort_by_key(|f| f.tag);
238        len += tagged_fields_len(&all_tags)?;
239        Ok(len)
240    }
241}