kacrab_protocol/generated/
list_partition_reassignments_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 ListPartitionReassignmentsRequestData {
17 pub timeout_ms: i32,
19 pub topics: Option<Vec<ListPartitionReassignmentsTopics>>,
21 pub _unknown_tagged_fields: Vec<RawTaggedField>,
22}
23impl Default for ListPartitionReassignmentsRequestData {
24 fn default() -> Self {
25 Self {
26 timeout_ms: 60000i32,
27 topics: None,
28 _unknown_tagged_fields: Vec::new(),
29 }
30 }
31}
32impl ListPartitionReassignmentsRequestData {
33 pub fn with_timeout_ms(mut self, value: i32) -> Self {
34 self.timeout_ms = value;
35 self
36 }
37 pub fn with_topics(mut self, value: Option<Vec<ListPartitionReassignmentsTopics>>) -> 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(46, version).into());
44 }
45 let timeout_ms;
46 let topics;
47 let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
48 timeout_ms = read_i32(buf)?;
49 topics = {
50 let len = read_compact_array_length(buf)?;
51 if len < 0 {
52 None
53 } else {
54 let mut arr = Vec::with_capacity(array_read_capacity(len, (buf).len()));
55 for _ in 0..len {
56 arr.push(ListPartitionReassignmentsTopics::read(buf, version)?);
57 }
58 Some(arr)
59 }
60 };
61 let tagged_fields = read_tagged_fields(buf)?;
62 for field in &tagged_fields {
63 match field.tag {
64 _ => {
65 _unknown_tagged_fields.push(field.clone());
66 },
67 }
68 }
69 Ok(Self {
70 timeout_ms,
71 topics,
72 _unknown_tagged_fields,
73 })
74 }
75 pub fn write(&self, buf: &mut BytesMut, version: i16) -> Result<()> {
76 if version < 0 || version > 0 {
77 return Err(UnsupportedVersion::new(46, version).into());
78 }
79 write_i32(buf, self.timeout_ms);
80 match &self.topics {
81 None => {
82 write_compact_array_length(buf, -1);
83 },
84 Some(arr) => {
85 write_compact_array_length(buf, arr.len() as i32);
86 for el in arr {
87 el.write(buf, version)?;
88 }
89 },
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(46, version).into());
99 }
100 let mut len: usize = 0;
101 len += 4;
102 match &self.topics {
103 None => {
104 len += compact_array_length_len(-1);
105 },
106 Some(arr) => {
107 len += compact_array_length_len(arr.len() as i32);
108 for el in arr {
109 len += el.encoded_len(version)?;
110 }
111 },
112 }
113 let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
114 all_tags.sort_by_key(|f| f.tag);
115 len += tagged_fields_len(&all_tags)?;
116 Ok(len)
117 }
118}
119#[derive(Debug, Clone, PartialEq)]
120pub struct ListPartitionReassignmentsTopics {
121 pub name: KafkaString,
123 pub partition_indexes: Vec<i32>,
125 pub _unknown_tagged_fields: Vec<RawTaggedField>,
126}
127impl Default for ListPartitionReassignmentsTopics {
128 fn default() -> Self {
129 Self {
130 name: KafkaString::default(),
131 partition_indexes: Vec::new(),
132 _unknown_tagged_fields: Vec::new(),
133 }
134 }
135}
136impl ListPartitionReassignmentsTopics {
137 pub fn with_name(mut self, value: KafkaString) -> Self {
138 self.name = value;
139 self
140 }
141 pub fn with_partition_indexes(mut self, value: Vec<i32>) -> Self {
142 self.partition_indexes = value;
143 self
144 }
145 pub fn read(buf: &mut Bytes, _version: i16) -> Result<Self> {
146 let name;
147 let partition_indexes;
148 let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
149 name = read_compact_string(buf)?;
150 partition_indexes = {
151 let len = read_compact_array_length(buf)?;
152 let mut arr = Vec::with_capacity(array_read_capacity(len, (buf).len()));
153 for _ in 0..len {
154 arr.push(read_i32(buf)?);
155 }
156 arr
157 };
158 let tagged_fields = read_tagged_fields(buf)?;
159 for field in &tagged_fields {
160 match field.tag {
161 _ => {
162 _unknown_tagged_fields.push(field.clone());
163 },
164 }
165 }
166 Ok(Self {
167 name,
168 partition_indexes,
169 _unknown_tagged_fields,
170 })
171 }
172 pub fn write(&self, buf: &mut BytesMut, _version: i16) -> Result<()> {
173 write_compact_string(buf, &self.name)?;
174 write_compact_array_length(buf, self.partition_indexes.len() as i32);
175 for el in &self.partition_indexes {
176 write_i32(buf, *el);
177 }
178 let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
179 all_tags.sort_by_key(|f| f.tag);
180 write_tagged_fields(buf, &all_tags)?;
181 Ok(())
182 }
183 pub fn encoded_len(&self, _version: i16) -> Result<usize> {
184 let mut len: usize = 0;
185 len += compact_string_len(&self.name)?;
186 len += compact_array_length_len(self.partition_indexes.len() as i32);
187 len += self.partition_indexes.len() * 4usize;
188 let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
189 all_tags.sort_by_key(|f| f.tag);
190 len += tagged_fields_len(&all_tags)?;
191 Ok(len)
192 }
193}