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