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