kacrab_protocol/generated/
alter_user_scram_credentials_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 AlterUserScramCredentialsRequestData {
17 pub deletions: Vec<ScramCredentialDeletion>,
19 pub upsertions: Vec<ScramCredentialUpsertion>,
21 pub _unknown_tagged_fields: Vec<RawTaggedField>,
22}
23impl Default for AlterUserScramCredentialsRequestData {
24 fn default() -> Self {
25 Self {
26 deletions: Vec::new(),
27 upsertions: Vec::new(),
28 _unknown_tagged_fields: Vec::new(),
29 }
30 }
31}
32impl AlterUserScramCredentialsRequestData {
33 pub fn with_deletions(mut self, value: Vec<ScramCredentialDeletion>) -> Self {
34 self.deletions = value;
35 self
36 }
37 pub fn with_upsertions(mut self, value: Vec<ScramCredentialUpsertion>) -> Self {
38 self.upsertions = value;
39 self
40 }
41 pub fn read(buf: &mut Bytes, version: i16) -> Result<Self> {
42 if version < 0 || version > 0 {
43 return Err(UnsupportedVersion::new(51, version).into());
44 }
45 let deletions;
46 let upsertions;
47 let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
48 deletions = {
49 let len = read_compact_array_length(buf)?;
50 let mut arr = Vec::with_capacity(array_read_capacity(len, (buf).len()));
51 for _ in 0..len {
52 arr.push(ScramCredentialDeletion::read(buf, version)?);
53 }
54 arr
55 };
56 upsertions = {
57 let len = read_compact_array_length(buf)?;
58 let mut arr = Vec::with_capacity(array_read_capacity(len, (buf).len()));
59 for _ in 0..len {
60 arr.push(ScramCredentialUpsertion::read(buf, version)?);
61 }
62 arr
63 };
64 let tagged_fields = read_tagged_fields(buf)?;
65 for field in &tagged_fields {
66 match field.tag {
67 _ => {
68 _unknown_tagged_fields.push(field.clone());
69 },
70 }
71 }
72 Ok(Self {
73 deletions,
74 upsertions,
75 _unknown_tagged_fields,
76 })
77 }
78 pub fn write(&self, buf: &mut BytesMut, version: i16) -> Result<()> {
79 if version < 0 || version > 0 {
80 return Err(UnsupportedVersion::new(51, version).into());
81 }
82 write_compact_array_length(buf, self.deletions.len() as i32);
83 for el in &self.deletions {
84 el.write(buf, version)?;
85 }
86 write_compact_array_length(buf, self.upsertions.len() as i32);
87 for el in &self.upsertions {
88 el.write(buf, version)?;
89 }
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 Ok(())
94 }
95 pub fn encoded_len(&self, version: i16) -> Result<usize> {
96 if version < 0 || version > 0 {
97 return Err(UnsupportedVersion::new(51, version).into());
98 }
99 let mut len: usize = 0;
100 len += compact_array_length_len(self.deletions.len() as i32);
101 for el in &self.deletions {
102 len += el.encoded_len(version)?;
103 }
104 len += compact_array_length_len(self.upsertions.len() as i32);
105 for el in &self.upsertions {
106 len += el.encoded_len(version)?;
107 }
108 let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
109 all_tags.sort_by_key(|f| f.tag);
110 len += tagged_fields_len(&all_tags)?;
111 Ok(len)
112 }
113}
114#[derive(Debug, Clone, PartialEq)]
115pub struct ScramCredentialDeletion {
116 pub name: KafkaString,
118 pub mechanism: i8,
120 pub _unknown_tagged_fields: Vec<RawTaggedField>,
121}
122impl Default for ScramCredentialDeletion {
123 fn default() -> Self {
124 Self {
125 name: KafkaString::default(),
126 mechanism: 0_i8,
127 _unknown_tagged_fields: Vec::new(),
128 }
129 }
130}
131impl ScramCredentialDeletion {
132 pub fn with_name(mut self, value: KafkaString) -> Self {
133 self.name = value;
134 self
135 }
136 pub fn with_mechanism(mut self, value: i8) -> Self {
137 self.mechanism = value;
138 self
139 }
140 pub fn read(buf: &mut Bytes, _version: i16) -> Result<Self> {
141 let name;
142 let mechanism;
143 let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
144 name = read_compact_string(buf)?;
145 mechanism = read_i8(buf)?;
146 let tagged_fields = read_tagged_fields(buf)?;
147 for field in &tagged_fields {
148 match field.tag {
149 _ => {
150 _unknown_tagged_fields.push(field.clone());
151 },
152 }
153 }
154 Ok(Self {
155 name,
156 mechanism,
157 _unknown_tagged_fields,
158 })
159 }
160 pub fn write(&self, buf: &mut BytesMut, _version: i16) -> Result<()> {
161 write_compact_string(buf, &self.name)?;
162 write_i8(buf, self.mechanism);
163 let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
164 all_tags.sort_by_key(|f| f.tag);
165 write_tagged_fields(buf, &all_tags)?;
166 Ok(())
167 }
168 pub fn encoded_len(&self, _version: i16) -> Result<usize> {
169 let mut len: usize = 0;
170 len += compact_string_len(&self.name)?;
171 len += 1;
172 let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
173 all_tags.sort_by_key(|f| f.tag);
174 len += tagged_fields_len(&all_tags)?;
175 Ok(len)
176 }
177}
178#[derive(Debug, Clone, PartialEq)]
179pub struct ScramCredentialUpsertion {
180 pub name: KafkaString,
182 pub mechanism: i8,
184 pub iterations: i32,
186 pub salt: Bytes,
188 pub salted_password: Bytes,
190 pub _unknown_tagged_fields: Vec<RawTaggedField>,
191}
192impl Default for ScramCredentialUpsertion {
193 fn default() -> Self {
194 Self {
195 name: KafkaString::default(),
196 mechanism: 0_i8,
197 iterations: 0_i32,
198 salt: Bytes::new(),
199 salted_password: Bytes::new(),
200 _unknown_tagged_fields: Vec::new(),
201 }
202 }
203}
204impl ScramCredentialUpsertion {
205 pub fn with_name(mut self, value: KafkaString) -> Self {
206 self.name = value;
207 self
208 }
209 pub fn with_mechanism(mut self, value: i8) -> Self {
210 self.mechanism = value;
211 self
212 }
213 pub fn with_iterations(mut self, value: i32) -> Self {
214 self.iterations = value;
215 self
216 }
217 pub fn with_salt(mut self, value: Bytes) -> Self {
218 self.salt = value;
219 self
220 }
221 pub fn with_salted_password(mut self, value: Bytes) -> Self {
222 self.salted_password = value;
223 self
224 }
225 pub fn read(buf: &mut Bytes, _version: i16) -> Result<Self> {
226 let name;
227 let mechanism;
228 let iterations;
229 let salt;
230 let salted_password;
231 let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
232 name = read_compact_string(buf)?;
233 mechanism = read_i8(buf)?;
234 iterations = read_i32(buf)?;
235 salt = read_compact_bytes(buf)?;
236 salted_password = read_compact_bytes(buf)?;
237 let tagged_fields = read_tagged_fields(buf)?;
238 for field in &tagged_fields {
239 match field.tag {
240 _ => {
241 _unknown_tagged_fields.push(field.clone());
242 },
243 }
244 }
245 Ok(Self {
246 name,
247 mechanism,
248 iterations,
249 salt,
250 salted_password,
251 _unknown_tagged_fields,
252 })
253 }
254 pub fn write(&self, buf: &mut BytesMut, _version: i16) -> Result<()> {
255 write_compact_string(buf, &self.name)?;
256 write_i8(buf, self.mechanism);
257 write_i32(buf, self.iterations);
258 write_compact_bytes(buf, &self.salt)?;
259 write_compact_bytes(buf, &self.salted_password)?;
260 let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
261 all_tags.sort_by_key(|f| f.tag);
262 write_tagged_fields(buf, &all_tags)?;
263 Ok(())
264 }
265 pub fn encoded_len(&self, _version: i16) -> Result<usize> {
266 let mut len: usize = 0;
267 len += compact_string_len(&self.name)?;
268 len += 1;
269 len += 4;
270 len += compact_bytes_len(&self.salt)?;
271 len += compact_bytes_len(&self.salted_password)?;
272 let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
273 all_tags.sort_by_key(|f| f.tag);
274 len += tagged_fields_len(&all_tags)?;
275 Ok(len)
276 }
277}