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