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