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