kacrab_protocol/generated/
alter_share_group_offsets_response.rs1#![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 AlterShareGroupOffsetsResponseData {
17 pub throttle_time_ms: i32,
20 pub error_code: i16,
22 pub error_message: Option<KafkaString>,
24 pub responses: Vec<AlterShareGroupOffsetsResponseTopic>,
26 pub _unknown_tagged_fields: Vec<RawTaggedField>,
27}
28impl Default for AlterShareGroupOffsetsResponseData {
29 fn default() -> Self {
30 Self {
31 throttle_time_ms: 0_i32,
32 error_code: 0_i16,
33 error_message: None,
34 responses: Vec::new(),
35 _unknown_tagged_fields: Vec::new(),
36 }
37 }
38}
39impl AlterShareGroupOffsetsResponseData {
40 pub fn with_throttle_time_ms(mut self, value: i32) -> Self {
41 self.throttle_time_ms = value;
42 self
43 }
44 pub fn with_error_code(mut self, value: i16) -> Self {
45 self.error_code = value;
46 self
47 }
48 pub fn with_error_message(mut self, value: Option<KafkaString>) -> Self {
49 self.error_message = value;
50 self
51 }
52 pub fn with_responses(mut self, value: Vec<AlterShareGroupOffsetsResponseTopic>) -> Self {
53 self.responses = value;
54 self
55 }
56 pub fn read(buf: &mut Bytes, version: i16) -> Result<Self> {
57 if version < 0 || version > 0 {
58 return Err(UnsupportedVersion::new(91, version).into());
59 }
60 let throttle_time_ms;
61 let error_code;
62 let error_message;
63 let responses;
64 let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
65 throttle_time_ms = read_i32(buf)?;
66 error_code = read_i16(buf)?;
67 error_message = read_compact_nullable_string(buf)?;
68 responses = {
69 let len = read_compact_array_length(buf)?;
70 let mut arr = Vec::with_capacity(array_read_capacity(len, (buf).len()));
71 for _ in 0..len {
72 arr.push(AlterShareGroupOffsetsResponseTopic::read(buf, version)?);
73 }
74 arr
75 };
76 let tagged_fields = read_tagged_fields(buf)?;
77 for field in &tagged_fields {
78 match field.tag {
79 _ => {
80 _unknown_tagged_fields.push(field.clone());
81 },
82 }
83 }
84 Ok(Self {
85 throttle_time_ms,
86 error_code,
87 error_message,
88 responses,
89 _unknown_tagged_fields,
90 })
91 }
92 pub fn write(&self, buf: &mut BytesMut, version: i16) -> Result<()> {
93 if version < 0 || version > 0 {
94 return Err(UnsupportedVersion::new(91, version).into());
95 }
96 write_i32(buf, self.throttle_time_ms);
97 write_i16(buf, self.error_code);
98 write_compact_nullable_string(buf, self.error_message.as_ref())?;
99 write_compact_array_length(buf, self.responses.len() as i32);
100 for el in &self.responses {
101 el.write(buf, version)?;
102 }
103 let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
104 all_tags.sort_by_key(|f| f.tag);
105 write_tagged_fields(buf, &all_tags)?;
106 Ok(())
107 }
108 pub fn encoded_len(&self, version: i16) -> Result<usize> {
109 if version < 0 || version > 0 {
110 return Err(UnsupportedVersion::new(91, version).into());
111 }
112 let mut len: usize = 0;
113 len += 4;
114 len += 2;
115 len += compact_nullable_string_len(self.error_message.as_ref())?;
116 len += compact_array_length_len(self.responses.len() as i32);
117 for el in &self.responses {
118 len += el.encoded_len(version)?;
119 }
120 let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
121 all_tags.sort_by_key(|f| f.tag);
122 len += tagged_fields_len(&all_tags)?;
123 Ok(len)
124 }
125}
126#[derive(Debug, Clone, PartialEq)]
127pub struct AlterShareGroupOffsetsResponseTopic {
128 pub topic_name: KafkaString,
130 pub topic_id: KafkaUuid,
132 pub partitions: Vec<AlterShareGroupOffsetsResponsePartition>,
133 pub _unknown_tagged_fields: Vec<RawTaggedField>,
134}
135impl Default for AlterShareGroupOffsetsResponseTopic {
136 fn default() -> Self {
137 Self {
138 topic_name: KafkaString::default(),
139 topic_id: KafkaUuid::ZERO,
140 partitions: Vec::new(),
141 _unknown_tagged_fields: Vec::new(),
142 }
143 }
144}
145impl AlterShareGroupOffsetsResponseTopic {
146 pub fn with_topic_name(mut self, value: KafkaString) -> Self {
147 self.topic_name = value;
148 self
149 }
150 pub fn with_topic_id(mut self, value: KafkaUuid) -> Self {
151 self.topic_id = value;
152 self
153 }
154 pub fn with_partitions(mut self, value: Vec<AlterShareGroupOffsetsResponsePartition>) -> Self {
155 self.partitions = value;
156 self
157 }
158 pub fn read(buf: &mut Bytes, version: i16) -> Result<Self> {
159 let topic_name;
160 let topic_id;
161 let partitions;
162 let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
163 topic_name = read_compact_string(buf)?;
164 topic_id = read_uuid(buf)?;
165 partitions = {
166 let len = read_compact_array_length(buf)?;
167 let mut arr = Vec::with_capacity(array_read_capacity(len, (buf).len()));
168 for _ in 0..len {
169 arr.push(AlterShareGroupOffsetsResponsePartition::read(buf, version)?);
170 }
171 arr
172 };
173 let tagged_fields = read_tagged_fields(buf)?;
174 for field in &tagged_fields {
175 match field.tag {
176 _ => {
177 _unknown_tagged_fields.push(field.clone());
178 },
179 }
180 }
181 Ok(Self {
182 topic_name,
183 topic_id,
184 partitions,
185 _unknown_tagged_fields,
186 })
187 }
188 pub fn write(&self, buf: &mut BytesMut, version: i16) -> Result<()> {
189 write_compact_string(buf, &self.topic_name)?;
190 write_uuid(buf, &self.topic_id);
191 write_compact_array_length(buf, self.partitions.len() as i32);
192 for el in &self.partitions {
193 el.write(buf, version)?;
194 }
195 let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
196 all_tags.sort_by_key(|f| f.tag);
197 write_tagged_fields(buf, &all_tags)?;
198 Ok(())
199 }
200 pub fn encoded_len(&self, version: i16) -> Result<usize> {
201 let mut len: usize = 0;
202 len += compact_string_len(&self.topic_name)?;
203 len += 16;
204 len += compact_array_length_len(self.partitions.len() as i32);
205 for el in &self.partitions {
206 len += el.encoded_len(version)?;
207 }
208 let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
209 all_tags.sort_by_key(|f| f.tag);
210 len += tagged_fields_len(&all_tags)?;
211 Ok(len)
212 }
213}
214#[derive(Debug, Clone, PartialEq)]
215pub struct AlterShareGroupOffsetsResponsePartition {
216 pub partition_index: i32,
218 pub error_code: i16,
220 pub error_message: Option<KafkaString>,
222 pub _unknown_tagged_fields: Vec<RawTaggedField>,
223}
224impl Default for AlterShareGroupOffsetsResponsePartition {
225 fn default() -> Self {
226 Self {
227 partition_index: 0_i32,
228 error_code: 0_i16,
229 error_message: None,
230 _unknown_tagged_fields: Vec::new(),
231 }
232 }
233}
234impl AlterShareGroupOffsetsResponsePartition {
235 pub fn with_partition_index(mut self, value: i32) -> Self {
236 self.partition_index = value;
237 self
238 }
239 pub fn with_error_code(mut self, value: i16) -> Self {
240 self.error_code = value;
241 self
242 }
243 pub fn with_error_message(mut self, value: Option<KafkaString>) -> Self {
244 self.error_message = value;
245 self
246 }
247 pub fn read(buf: &mut Bytes, _version: i16) -> Result<Self> {
248 let partition_index;
249 let error_code;
250 let error_message;
251 let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
252 partition_index = read_i32(buf)?;
253 error_code = read_i16(buf)?;
254 error_message = read_compact_nullable_string(buf)?;
255 let tagged_fields = read_tagged_fields(buf)?;
256 for field in &tagged_fields {
257 match field.tag {
258 _ => {
259 _unknown_tagged_fields.push(field.clone());
260 },
261 }
262 }
263 Ok(Self {
264 partition_index,
265 error_code,
266 error_message,
267 _unknown_tagged_fields,
268 })
269 }
270 pub fn write(&self, buf: &mut BytesMut, _version: i16) -> Result<()> {
271 write_i32(buf, self.partition_index);
272 write_i16(buf, self.error_code);
273 write_compact_nullable_string(buf, self.error_message.as_ref())?;
274 let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
275 all_tags.sort_by_key(|f| f.tag);
276 write_tagged_fields(buf, &all_tags)?;
277 Ok(())
278 }
279 pub fn encoded_len(&self, _version: i16) -> Result<usize> {
280 let mut len: usize = 0;
281 len += 4;
282 len += 2;
283 len += compact_nullable_string_len(self.error_message.as_ref())?;
284 let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
285 all_tags.sort_by_key(|f| f.tag);
286 len += tagged_fields_len(&all_tags)?;
287 Ok(len)
288 }
289}