kacrab_protocol/generated/
delete_groups_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 DeleteGroupsRequestData {
17 pub groups_names: Vec<KafkaString>,
19 pub _unknown_tagged_fields: Vec<RawTaggedField>,
20}
21impl Default for DeleteGroupsRequestData {
22 fn default() -> Self {
23 Self {
24 groups_names: Vec::new(),
25 _unknown_tagged_fields: Vec::new(),
26 }
27 }
28}
29impl DeleteGroupsRequestData {
30 pub fn with_groups_names(mut self, value: Vec<KafkaString>) -> Self {
31 self.groups_names = value;
32 self
33 }
34 pub fn read(buf: &mut Bytes, version: i16) -> Result<Self> {
35 if version < 0 || version > 2 {
36 return Err(UnsupportedVersion::new(42, version).into());
37 }
38 let groups_names;
39 let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
40 if version >= 2 {
41 groups_names = {
42 let len = read_compact_array_length(buf)?;
43 let mut arr = Vec::with_capacity(len.max(0) as usize);
44 for _ in 0..len {
45 arr.push(read_compact_string(buf)?);
46 }
47 arr
48 };
49 } else {
50 groups_names = {
51 let len = read_array_length(buf)?;
52 let mut arr = Vec::with_capacity(len.max(0) as usize);
53 for _ in 0..len {
54 arr.push(read_string(buf)?);
55 }
56 arr
57 };
58 }
59 if version >= 2 {
60 let tagged_fields = read_tagged_fields(buf)?;
61 for field in &tagged_fields {
62 match field.tag {
63 _ => {
64 _unknown_tagged_fields.push(field.clone());
65 },
66 }
67 }
68 }
69 Ok(Self {
70 groups_names,
71 _unknown_tagged_fields,
72 })
73 }
74 pub fn write(&self, buf: &mut BytesMut, version: i16) -> Result<()> {
75 if version < 0 || version > 2 {
76 return Err(UnsupportedVersion::new(42, version).into());
77 }
78 if version >= 2 {
79 write_compact_array_length(buf, self.groups_names.len() as i32);
80 for el in &self.groups_names {
81 write_compact_string(buf, el)?;
82 }
83 } else {
84 write_array_length(buf, self.groups_names.len() as i32);
85 for el in &self.groups_names {
86 write_string(buf, el)?;
87 }
88 }
89 if version >= 2 {
90 let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
91 all_tags.sort_by_key(|f| f.tag);
92 write_tagged_fields(buf, &all_tags)?;
93 }
94 Ok(())
95 }
96 pub fn encoded_len(&self, version: i16) -> Result<usize> {
97 if version < 0 || version > 2 {
98 return Err(UnsupportedVersion::new(42, version).into());
99 }
100 let mut len: usize = 0;
101 if version >= 2 {
102 len += compact_array_length_len(self.groups_names.len() as i32);
103 for el in &self.groups_names {
104 len += compact_string_len(el)?;
105 }
106 } else {
107 len += array_length_len();
108 for el in &self.groups_names {
109 len += string_len(el)?;
110 }
111 }
112 if version >= 2 {
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 }
117 Ok(len)
118 }
119}