Skip to main content

crabka_protocol/opt/rustwide/workdir/generated/
DeleteShareGroupOffsetsResponse.owned.rs

1// AUTO-GENERATED by crabka-protocol-codegen against a9ce3221537b8653448750697915607dc7936cf3. Do not edit.
2
3use crate::primitives::fixed::{get_i16, get_i32, put_i16, put_i32};
4use crate::primitives::string_bytes::{
5    compact_nullable_string_len, compact_string_len, get_compact_nullable_string_owned,
6    get_compact_string_owned, get_nullable_string_owned, get_string_owned, nullable_string_len,
7    put_compact_nullable_string, put_compact_string, put_nullable_string, put_string, string_len,
8};
9use crate::tagged_fields::{WriteTaggedFields, read_tagged_fields, tagged_fields_len};
10use crate::{Decode, Encode, ProtocolError, UnknownTaggedFields};
11use bytes::{Buf, BufMut};
12pub const API_KEY: i16 = 92;
13pub const MIN_VERSION: i16 = 0;
14pub const MAX_VERSION: i16 = 0;
15pub const FLEXIBLE_MIN: i16 = 0;
16#[inline]
17fn is_flexible(version: i16) -> bool {
18    version >= FLEXIBLE_MIN
19}
20#[derive(Debug, Clone, PartialEq, Eq, Default)]
21pub struct DeleteShareGroupOffsetsResponse {
22    pub throttle_time_ms: i32,
23    pub error_code: i16,
24    pub error_message: Option<String>,
25    pub responses: Vec<DeleteShareGroupOffsetsResponseTopic>,
26    pub unknown_tagged_fields: UnknownTaggedFields,
27}
28impl Encode for DeleteShareGroupOffsetsResponse {
29    fn encode<B: BufMut>(&self, buf: &mut B, version: i16) -> Result<(), ProtocolError> {
30        if !(MIN_VERSION..=MAX_VERSION).contains(&version) {
31            return Err(ProtocolError::UnsupportedVersion {
32                api_key: API_KEY,
33                version,
34            });
35        }
36        let flex = is_flexible(version);
37        if version >= 0 {
38            put_i32(buf, self.throttle_time_ms);
39        }
40        if version >= 0 {
41            put_i16(buf, self.error_code);
42        }
43        if version >= 0 {
44            if flex {
45                put_compact_nullable_string(buf, self.error_message.as_deref());
46            } else {
47                put_nullable_string(buf, self.error_message.as_deref());
48            }
49        }
50        if version >= 0 {
51            {
52                crate::primitives::array::put_array_len(buf, (self.responses).len(), flex);
53                for it in &self.responses {
54                    it.encode(buf, version)?;
55                }
56            }
57        }
58        if flex {
59            let tagged = WriteTaggedFields::new();
60            tagged.write(buf, &self.unknown_tagged_fields);
61        }
62        Ok(())
63    }
64    fn encoded_len(&self, version: i16) -> usize {
65        let flex = is_flexible(version);
66        let mut n: usize = 0;
67        if version >= 0 {
68            n += 4;
69        }
70        if version >= 0 {
71            n += 2;
72        }
73        if version >= 0 {
74            n += if flex {
75                compact_nullable_string_len(self.error_message.as_deref())
76            } else {
77                nullable_string_len(self.error_message.as_deref())
78            };
79        }
80        if version >= 0 {
81            n += {
82                let prefix =
83                    crate::primitives::array::array_len_prefix_len((self.responses).len(), flex);
84                let body: usize = (self.responses)
85                    .iter()
86                    .map(|it| it.encoded_len(version))
87                    .sum();
88                prefix + body
89            };
90        }
91        if flex {
92            let known_pairs: Vec<(u32, usize)> = Vec::new();
93            n += tagged_fields_len(&known_pairs, &self.unknown_tagged_fields);
94        }
95        n
96    }
97}
98impl Decode<'_> for DeleteShareGroupOffsetsResponse {
99    fn decode<B: Buf>(buf: &mut B, version: i16) -> Result<Self, ProtocolError> {
100        if !(MIN_VERSION..=MAX_VERSION).contains(&version) {
101            return Err(ProtocolError::UnsupportedVersion {
102                api_key: API_KEY,
103                version,
104            });
105        }
106        let flex = is_flexible(version);
107        let mut out = Self::default();
108        if version >= 0 {
109            out.throttle_time_ms = get_i32(buf)?;
110        }
111        if version >= 0 {
112            out.error_code = get_i16(buf)?;
113        }
114        if version >= 0 {
115            out.error_message = if flex {
116                get_compact_nullable_string_owned(buf)?
117            } else {
118                get_nullable_string_owned(buf)?
119            };
120        }
121        if version >= 0 {
122            out.responses = {
123                let n = crate::primitives::array::get_array_len(buf, flex)?;
124                let mut v = Vec::with_capacity(n);
125                for _ in 0..n {
126                    v.push(DeleteShareGroupOffsetsResponseTopic::decode(buf, version)?);
127                }
128                v
129            };
130        }
131        if flex {
132            out.unknown_tagged_fields = read_tagged_fields(buf, |_tag, _payload| Ok(false))?;
133        }
134        Ok(out)
135    }
136}
137#[cfg(test)]
138impl DeleteShareGroupOffsetsResponse {
139    #[must_use]
140    pub fn populated(version: i16) -> Self {
141        let mut m = Self::default();
142        if version >= 0 {
143            m.throttle_time_ms = 1i32;
144        }
145        if version >= 0 {
146            m.error_code = 1i16;
147        }
148        if version >= 0 {
149            m.error_message = Some("x".to_string());
150        }
151        if version >= 0 {
152            m.responses = vec![DeleteShareGroupOffsetsResponseTopic::populated(version)];
153        }
154        m
155    }
156}
157#[derive(Debug, Clone, PartialEq, Eq, Default)]
158pub struct DeleteShareGroupOffsetsResponseTopic {
159    pub topic_name: String,
160    pub topic_id: crate::primitives::uuid::Uuid,
161    pub error_code: i16,
162    pub error_message: Option<String>,
163    pub unknown_tagged_fields: UnknownTaggedFields,
164}
165impl Encode for DeleteShareGroupOffsetsResponseTopic {
166    fn encode<B: BufMut>(&self, buf: &mut B, version: i16) -> Result<(), ProtocolError> {
167        let flex = version >= 0;
168        if version >= 0 {
169            if flex {
170                put_compact_string(buf, &self.topic_name);
171            } else {
172                put_string(buf, &self.topic_name);
173            }
174        }
175        if version >= 0 {
176            crate::primitives::uuid::put_uuid(buf, self.topic_id);
177        }
178        if version >= 0 {
179            put_i16(buf, self.error_code);
180        }
181        if version >= 0 {
182            if flex {
183                put_compact_nullable_string(buf, self.error_message.as_deref());
184            } else {
185                put_nullable_string(buf, self.error_message.as_deref());
186            }
187        }
188        if flex {
189            let tagged = WriteTaggedFields::new();
190            tagged.write(buf, &self.unknown_tagged_fields);
191        }
192        Ok(())
193    }
194    fn encoded_len(&self, version: i16) -> usize {
195        let flex = version >= 0;
196        let mut n: usize = 0;
197        if version >= 0 {
198            n += if flex {
199                compact_string_len(&self.topic_name)
200            } else {
201                string_len(&self.topic_name)
202            };
203        }
204        if version >= 0 {
205            n += 16;
206        }
207        if version >= 0 {
208            n += 2;
209        }
210        if version >= 0 {
211            n += if flex {
212                compact_nullable_string_len(self.error_message.as_deref())
213            } else {
214                nullable_string_len(self.error_message.as_deref())
215            };
216        }
217        if flex {
218            let known_pairs: Vec<(u32, usize)> = Vec::new();
219            n += tagged_fields_len(&known_pairs, &self.unknown_tagged_fields);
220        }
221        n
222    }
223}
224impl Decode<'_> for DeleteShareGroupOffsetsResponseTopic {
225    fn decode<B: Buf>(buf: &mut B, version: i16) -> Result<Self, ProtocolError> {
226        let flex = version >= 0;
227        let mut out = Self::default();
228        if version >= 0 {
229            out.topic_name = if flex {
230                get_compact_string_owned(buf)?
231            } else {
232                get_string_owned(buf)?
233            };
234        }
235        if version >= 0 {
236            out.topic_id = crate::primitives::uuid::get_uuid(buf)?;
237        }
238        if version >= 0 {
239            out.error_code = get_i16(buf)?;
240        }
241        if version >= 0 {
242            out.error_message = if flex {
243                get_compact_nullable_string_owned(buf)?
244            } else {
245                get_nullable_string_owned(buf)?
246            };
247        }
248        if flex {
249            out.unknown_tagged_fields = read_tagged_fields(buf, |_tag, _payload| Ok(false))?;
250        }
251        Ok(out)
252    }
253}
254#[cfg(test)]
255impl DeleteShareGroupOffsetsResponseTopic {
256    #[must_use]
257    pub fn populated(version: i16) -> Self {
258        let mut m = Self::default();
259        if version >= 0 {
260            m.topic_name = "x".to_string();
261        }
262        if version >= 0 {
263            m.topic_id = crate::primitives::uuid::Uuid([1u8; 16]);
264        }
265        if version >= 0 {
266            m.error_code = 1i16;
267        }
268        if version >= 0 {
269            m.error_message = Some("x".to_string());
270        }
271        m
272    }
273}
274/// Default JSON payload matching `Self::default()` for JVM oracle differential testing.
275/// Only includes fields valid for the given version.
276#[must_use]
277#[allow(unused_comparisons)]
278pub fn default_json(version: i16) -> ::serde_json::Value {
279    let mut obj = ::serde_json::Map::new();
280    obj.insert("throttleTimeMs".to_string(), ::serde_json::json!(0));
281    obj.insert("errorCode".to_string(), ::serde_json::json!(0));
282    obj.insert("errorMessage".to_string(), ::serde_json::Value::Null);
283    obj.insert("responses".to_string(), ::serde_json::Value::Array(vec![]));
284    ::serde_json::Value::Object(obj)
285}