kacrab_protocol/generated/
describe_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 DescribeUserScramCredentialsRequestData {
17 pub users: Option<Vec<UserName>>,
19 pub _unknown_tagged_fields: Vec<RawTaggedField>,
20}
21impl Default for DescribeUserScramCredentialsRequestData {
22 fn default() -> Self {
23 Self {
24 users: None,
25 _unknown_tagged_fields: Vec::new(),
26 }
27 }
28}
29impl DescribeUserScramCredentialsRequestData {
30 pub fn with_users(mut self, value: Option<Vec<UserName>>) -> Self {
31 self.users = value;
32 self
33 }
34 pub fn read(buf: &mut Bytes, version: i16) -> Result<Self> {
35 if version < 0 || version > 0 {
36 return Err(UnsupportedVersion::new(50, version).into());
37 }
38 let users;
39 let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
40 users = {
41 let len = read_compact_array_length(buf)?;
42 if len < 0 {
43 None
44 } else {
45 let mut arr = Vec::with_capacity(array_read_capacity(len, (buf).len()));
46 for _ in 0..len {
47 arr.push(UserName::read(buf, version)?);
48 }
49 Some(arr)
50 }
51 };
52 let tagged_fields = read_tagged_fields(buf)?;
53 for field in &tagged_fields {
54 match field.tag {
55 _ => {
56 _unknown_tagged_fields.push(field.clone());
57 },
58 }
59 }
60 Ok(Self {
61 users,
62 _unknown_tagged_fields,
63 })
64 }
65 pub fn write(&self, buf: &mut BytesMut, version: i16) -> Result<()> {
66 if version < 0 || version > 0 {
67 return Err(UnsupportedVersion::new(50, version).into());
68 }
69 match &self.users {
70 None => {
71 write_compact_array_length(buf, -1);
72 },
73 Some(arr) => {
74 write_compact_array_length(buf, arr.len() as i32);
75 for el in arr {
76 el.write(buf, version)?;
77 }
78 },
79 }
80 let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
81 all_tags.sort_by_key(|f| f.tag);
82 write_tagged_fields(buf, &all_tags)?;
83 Ok(())
84 }
85 pub fn encoded_len(&self, version: i16) -> Result<usize> {
86 if version < 0 || version > 0 {
87 return Err(UnsupportedVersion::new(50, version).into());
88 }
89 let mut len: usize = 0;
90 match &self.users {
91 None => {
92 len += compact_array_length_len(-1);
93 },
94 Some(arr) => {
95 len += compact_array_length_len(arr.len() as i32);
96 for el in arr {
97 len += el.encoded_len(version)?;
98 }
99 },
100 }
101 let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
102 all_tags.sort_by_key(|f| f.tag);
103 len += tagged_fields_len(&all_tags)?;
104 Ok(len)
105 }
106}
107#[derive(Debug, Clone, PartialEq)]
108pub struct UserName {
109 pub name: KafkaString,
111 pub _unknown_tagged_fields: Vec<RawTaggedField>,
112}
113impl Default for UserName {
114 fn default() -> Self {
115 Self {
116 name: KafkaString::default(),
117 _unknown_tagged_fields: Vec::new(),
118 }
119 }
120}
121impl UserName {
122 pub fn with_name(mut self, value: KafkaString) -> Self {
123 self.name = value;
124 self
125 }
126 pub fn read(buf: &mut Bytes, _version: i16) -> Result<Self> {
127 let name;
128 let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
129 name = read_compact_string(buf)?;
130 let tagged_fields = read_tagged_fields(buf)?;
131 for field in &tagged_fields {
132 match field.tag {
133 _ => {
134 _unknown_tagged_fields.push(field.clone());
135 },
136 }
137 }
138 Ok(Self {
139 name,
140 _unknown_tagged_fields,
141 })
142 }
143 pub fn write(&self, buf: &mut BytesMut, _version: i16) -> Result<()> {
144 write_compact_string(buf, &self.name)?;
145 let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
146 all_tags.sort_by_key(|f| f.tag);
147 write_tagged_fields(buf, &all_tags)?;
148 Ok(())
149 }
150 pub fn encoded_len(&self, _version: i16) -> Result<usize> {
151 let mut len: usize = 0;
152 len += compact_string_len(&self.name)?;
153 let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
154 all_tags.sort_by_key(|f| f.tag);
155 len += tagged_fields_len(&all_tags)?;
156 Ok(len)
157 }
158}