kacrab_protocol/generated/
list_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 ListTransactionsResponseData {
17 pub throttle_time_ms: i32,
20 pub error_code: i16,
22 pub unknown_state_filters: Vec<KafkaString>,
25 pub transaction_states: Vec<TransactionState>,
27 pub _unknown_tagged_fields: Vec<RawTaggedField>,
28}
29impl Default for ListTransactionsResponseData {
30 fn default() -> Self {
31 Self {
32 throttle_time_ms: 0_i32,
33 error_code: 0_i16,
34 unknown_state_filters: Vec::new(),
35 transaction_states: Vec::new(),
36 _unknown_tagged_fields: Vec::new(),
37 }
38 }
39}
40impl ListTransactionsResponseData {
41 pub fn with_throttle_time_ms(mut self, value: i32) -> Self {
42 self.throttle_time_ms = value;
43 self
44 }
45 pub fn with_error_code(mut self, value: i16) -> Self {
46 self.error_code = value;
47 self
48 }
49 pub fn with_unknown_state_filters(mut self, value: Vec<KafkaString>) -> Self {
50 self.unknown_state_filters = value;
51 self
52 }
53 pub fn with_transaction_states(mut self, value: Vec<TransactionState>) -> Self {
54 self.transaction_states = value;
55 self
56 }
57 pub fn read(buf: &mut Bytes, version: i16) -> Result<Self> {
58 if version < 0 || version > 2 {
59 return Err(UnsupportedVersion::new(66, version).into());
60 }
61 let throttle_time_ms;
62 let error_code;
63 let unknown_state_filters;
64 let transaction_states;
65 let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
66 throttle_time_ms = read_i32(buf)?;
67 error_code = read_i16(buf)?;
68 unknown_state_filters = {
69 let len = read_compact_array_length(buf)?;
70 let mut arr = Vec::with_capacity(array_read_capacity(len, (buf).len()));
71 for _ in 0..len {
72 arr.push(read_compact_string(buf)?);
73 }
74 arr
75 };
76 transaction_states = {
77 let len = read_compact_array_length(buf)?;
78 let mut arr = Vec::with_capacity(array_read_capacity(len, (buf).len()));
79 for _ in 0..len {
80 arr.push(TransactionState::read(buf, version)?);
81 }
82 arr
83 };
84 let tagged_fields = read_tagged_fields(buf)?;
85 for field in &tagged_fields {
86 match field.tag {
87 _ => {
88 _unknown_tagged_fields.push(field.clone());
89 },
90 }
91 }
92 Ok(Self {
93 throttle_time_ms,
94 error_code,
95 unknown_state_filters,
96 transaction_states,
97 _unknown_tagged_fields,
98 })
99 }
100 pub fn write(&self, buf: &mut BytesMut, version: i16) -> Result<()> {
101 if version < 0 || version > 2 {
102 return Err(UnsupportedVersion::new(66, version).into());
103 }
104 write_i32(buf, self.throttle_time_ms);
105 write_i16(buf, self.error_code);
106 write_compact_array_length(buf, self.unknown_state_filters.len() as i32);
107 for el in &self.unknown_state_filters {
108 write_compact_string(buf, el)?;
109 }
110 write_compact_array_length(buf, self.transaction_states.len() as i32);
111 for el in &self.transaction_states {
112 el.write(buf, version)?;
113 }
114 let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
115 all_tags.sort_by_key(|f| f.tag);
116 write_tagged_fields(buf, &all_tags)?;
117 Ok(())
118 }
119 pub fn encoded_len(&self, version: i16) -> Result<usize> {
120 if version < 0 || version > 2 {
121 return Err(UnsupportedVersion::new(66, version).into());
122 }
123 let mut len: usize = 0;
124 len += 4;
125 len += 2;
126 len += compact_array_length_len(self.unknown_state_filters.len() as i32);
127 for el in &self.unknown_state_filters {
128 len += compact_string_len(el)?;
129 }
130 len += compact_array_length_len(self.transaction_states.len() as i32);
131 for el in &self.transaction_states {
132 len += el.encoded_len(version)?;
133 }
134 let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
135 all_tags.sort_by_key(|f| f.tag);
136 len += tagged_fields_len(&all_tags)?;
137 Ok(len)
138 }
139}
140#[derive(Debug, Clone, PartialEq)]
141pub struct TransactionState {
142 pub transactional_id: KafkaString,
144 pub producer_id: i64,
146 pub transaction_state: KafkaString,
148 pub _unknown_tagged_fields: Vec<RawTaggedField>,
149}
150impl Default for TransactionState {
151 fn default() -> Self {
152 Self {
153 transactional_id: KafkaString::default(),
154 producer_id: 0_i64,
155 transaction_state: KafkaString::default(),
156 _unknown_tagged_fields: Vec::new(),
157 }
158 }
159}
160impl TransactionState {
161 pub fn with_transactional_id(mut self, value: KafkaString) -> Self {
162 self.transactional_id = value;
163 self
164 }
165 pub fn with_producer_id(mut self, value: i64) -> Self {
166 self.producer_id = value;
167 self
168 }
169 pub fn with_transaction_state(mut self, value: KafkaString) -> Self {
170 self.transaction_state = value;
171 self
172 }
173 pub fn read(buf: &mut Bytes, _version: i16) -> Result<Self> {
174 let transactional_id;
175 let producer_id;
176 let transaction_state;
177 let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
178 transactional_id = read_compact_string(buf)?;
179 producer_id = read_i64(buf)?;
180 transaction_state = read_compact_string(buf)?;
181 let tagged_fields = read_tagged_fields(buf)?;
182 for field in &tagged_fields {
183 match field.tag {
184 _ => {
185 _unknown_tagged_fields.push(field.clone());
186 },
187 }
188 }
189 Ok(Self {
190 transactional_id,
191 producer_id,
192 transaction_state,
193 _unknown_tagged_fields,
194 })
195 }
196 pub fn write(&self, buf: &mut BytesMut, _version: i16) -> Result<()> {
197 write_compact_string(buf, &self.transactional_id)?;
198 write_i64(buf, self.producer_id);
199 write_compact_string(buf, &self.transaction_state)?;
200 let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
201 all_tags.sort_by_key(|f| f.tag);
202 write_tagged_fields(buf, &all_tags)?;
203 Ok(())
204 }
205 pub fn encoded_len(&self, _version: i16) -> Result<usize> {
206 let mut len: usize = 0;
207 len += compact_string_len(&self.transactional_id)?;
208 len += 8;
209 len += compact_string_len(&self.transaction_state)?;
210 let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
211 all_tags.sort_by_key(|f| f.tag);
212 len += tagged_fields_len(&all_tags)?;
213 Ok(len)
214 }
215}