kacrab_protocol/generated/
describe_transactions_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 DescribeTransactionsRequestData {
17 pub transactional_ids: Vec<KafkaString>,
20 pub _unknown_tagged_fields: Vec<RawTaggedField>,
21}
22impl Default for DescribeTransactionsRequestData {
23 fn default() -> Self {
24 Self {
25 transactional_ids: Vec::new(),
26 _unknown_tagged_fields: Vec::new(),
27 }
28 }
29}
30impl DescribeTransactionsRequestData {
31 pub fn with_transactional_ids(mut self, value: Vec<KafkaString>) -> Self {
32 self.transactional_ids = value;
33 self
34 }
35 pub fn read(buf: &mut Bytes, version: i16) -> Result<Self> {
36 if version < 0 || version > 0 {
37 return Err(UnsupportedVersion::new(65, version).into());
38 }
39 let transactional_ids;
40 let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
41 transactional_ids = {
42 let len = read_compact_array_length(buf)?;
43 let mut arr = Vec::with_capacity(array_read_capacity(len, (buf).len()));
44 for _ in 0..len {
45 arr.push(read_compact_string(buf)?);
46 }
47 arr
48 };
49 let tagged_fields = read_tagged_fields(buf)?;
50 for field in &tagged_fields {
51 match field.tag {
52 _ => {
53 _unknown_tagged_fields.push(field.clone());
54 },
55 }
56 }
57 Ok(Self {
58 transactional_ids,
59 _unknown_tagged_fields,
60 })
61 }
62 pub fn write(&self, buf: &mut BytesMut, version: i16) -> Result<()> {
63 if version < 0 || version > 0 {
64 return Err(UnsupportedVersion::new(65, version).into());
65 }
66 write_compact_array_length(buf, self.transactional_ids.len() as i32);
67 for el in &self.transactional_ids {
68 write_compact_string(buf, el)?;
69 }
70 let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
71 all_tags.sort_by_key(|f| f.tag);
72 write_tagged_fields(buf, &all_tags)?;
73 Ok(())
74 }
75 pub fn encoded_len(&self, version: i16) -> Result<usize> {
76 if version < 0 || version > 0 {
77 return Err(UnsupportedVersion::new(65, version).into());
78 }
79 let mut len: usize = 0;
80 len += compact_array_length_len(self.transactional_ids.len() as i32);
81 for el in &self.transactional_ids {
82 len += compact_string_len(el)?;
83 }
84 let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
85 all_tags.sort_by_key(|f| f.tag);
86 len += tagged_fields_len(&all_tags)?;
87 Ok(len)
88 }
89}