crabka_protocol/opt/rustwide/workdir/generated/
AlterShareGroupOffsetsResponse.owned.rs1use bytes::{Buf, BufMut};
4
5use crate::primitives::fixed::{get_i16, get_i32, put_i16, put_i32};
6use crate::primitives::string_bytes::{
7 compact_nullable_string_len, compact_string_len, get_compact_nullable_string_owned,
8 get_compact_string_owned, get_nullable_string_owned, get_string_owned, nullable_string_len,
9 put_compact_nullable_string, put_compact_string, put_nullable_string, put_string,
10 string_len,
11};
12use crate::tagged_fields::{read_tagged_fields, tagged_fields_len, WriteTaggedFields};
13use crate::{Decode, Encode, ProtocolError, UnknownTaggedFields};
14
15pub const API_KEY: i16 = 91;
16pub const MIN_VERSION: i16 = 0;
17pub const MAX_VERSION: i16 = 0;
18pub const FLEXIBLE_MIN: i16 = 0;
19
20#[inline]
21fn is_flexible(version: i16) -> bool { version >= FLEXIBLE_MIN }
22
23#[derive(Debug, Clone, PartialEq, Eq, Default)]
24pub struct AlterShareGroupOffsetsResponse {
25 pub throttle_time_ms: i32,
26 pub error_code: i16,
27 pub error_message: Option<String>,
28 pub responses: Vec<AlterShareGroupOffsetsResponseTopic>,
29 pub unknown_tagged_fields: UnknownTaggedFields,
30}
31
32impl Encode for AlterShareGroupOffsetsResponse {
33 fn encode<B: BufMut>(&self, buf: &mut B, version: i16) -> Result<(), ProtocolError> {
34 if !(MIN_VERSION..=MAX_VERSION).contains(&version) {
35 return Err(ProtocolError::UnsupportedVersion { api_key: API_KEY, version });
36 }
37 let flex = is_flexible(version);
38 if version >= 0 { put_i32(buf, self.throttle_time_ms) }
39 if version >= 0 { put_i16(buf, self.error_code) }
40 if version >= 0 { if flex { put_compact_nullable_string(buf, self.error_message.as_deref()) } else { put_nullable_string(buf, self.error_message.as_deref()) } }
41 if version >= 0 { { crate::primitives::array::put_array_len(buf, (self.responses).len(), flex); for it in &self.responses { it.encode(buf, version)?; } } }
42 if flex {
43 let tagged = WriteTaggedFields::new();
44 tagged.write(buf, &self.unknown_tagged_fields);
45 }
46 Ok(())
47 }
48 fn encoded_len(&self, version: i16) -> usize {
49 let flex = is_flexible(version);
50 let mut n: usize = 0;
51 if version >= 0 { n += 4; }
52 if version >= 0 { n += 2; }
53 if version >= 0 { n += if flex { compact_nullable_string_len(self.error_message.as_deref()) } else { nullable_string_len(self.error_message.as_deref()) }; }
54 if version >= 0 { n += { let prefix = crate::primitives::array::array_len_prefix_len((self.responses).len(), flex); let body: usize = (self.responses).iter().map(|it| it.encoded_len(version)).sum(); prefix + body }; }
55 if flex {
56 let known_pairs: Vec<(u32, usize)> = Vec::new();
57 n += tagged_fields_len(&known_pairs, &self.unknown_tagged_fields);
58 }
59 n
60 }
61}
62
63impl<'de> Decode<'de> for AlterShareGroupOffsetsResponse {
64 fn decode<B: Buf>(buf: &mut B, version: i16) -> Result<Self, ProtocolError> {
65 if !(MIN_VERSION..=MAX_VERSION).contains(&version) {
66 return Err(ProtocolError::UnsupportedVersion { api_key: API_KEY, version });
67 }
68 let flex = is_flexible(version);
69 let mut out = Self::default();
70 if version >= 0 { out.throttle_time_ms = get_i32(buf)?; }
71 if version >= 0 { out.error_code = get_i16(buf)?; }
72 if version >= 0 { out.error_message = if flex { get_compact_nullable_string_owned(buf)? } else { get_nullable_string_owned(buf)? }; }
73 if version >= 0 { out.responses = { let n = crate::primitives::array::get_array_len(buf, flex)?; let mut v = Vec::with_capacity(n); for _ in 0..n { v.push(AlterShareGroupOffsetsResponseTopic::decode(buf, version)?); } v }; }
74 if flex {
75 out.unknown_tagged_fields = read_tagged_fields(buf, |_tag, _payload| {
76 Ok(false)
77 })?;
78 }
79 Ok(out)
80 }
81}
82
83#[derive(Debug, Clone, PartialEq, Eq, Default)]
84pub struct AlterShareGroupOffsetsResponseTopic {
85 pub topic_name: String,
86 pub topic_id: crate::primitives::uuid::Uuid,
87 pub partitions: Vec<AlterShareGroupOffsetsResponsePartition>,
88 pub unknown_tagged_fields: UnknownTaggedFields,
89}
90
91impl Encode for AlterShareGroupOffsetsResponseTopic {
92 fn encode<B: BufMut>(&self, buf: &mut B, version: i16) -> Result<(), ProtocolError> {
93 let flex = version >= 0;
94 if version >= 0 { if flex { put_compact_string(buf, &self.topic_name) } else { put_string(buf, &self.topic_name) } }
95 if version >= 0 { crate::primitives::uuid::put_uuid(buf, self.topic_id) }
96 if version >= 0 { { crate::primitives::array::put_array_len(buf, (self.partitions).len(), flex); for it in &self.partitions { it.encode(buf, version)?; } } }
97 if flex {
98 let tagged = WriteTaggedFields::new();
99 tagged.write(buf, &self.unknown_tagged_fields);
100 }
101 Ok(())
102 }
103 fn encoded_len(&self, version: i16) -> usize {
104 let flex = version >= 0;
105 let mut n: usize = 0;
106 if version >= 0 { n += if flex { compact_string_len(&self.topic_name) } else { string_len(&self.topic_name) }; }
107 if version >= 0 { n += 16; }
108 if version >= 0 { n += { let prefix = crate::primitives::array::array_len_prefix_len((self.partitions).len(), flex); let body: usize = (self.partitions).iter().map(|it| it.encoded_len(version)).sum(); prefix + body }; }
109 if flex {
110 let known_pairs: Vec<(u32, usize)> = Vec::new();
111 n += tagged_fields_len(&known_pairs, &self.unknown_tagged_fields);
112 }
113 n
114 }
115}
116
117impl<'de> Decode<'de> for AlterShareGroupOffsetsResponseTopic {
118 fn decode<B: Buf>(buf: &mut B, version: i16) -> Result<Self, ProtocolError> {
119 let flex = version >= 0;
120 let mut out = Self::default();
121 if version >= 0 { out.topic_name = if flex { get_compact_string_owned(buf)? } else { get_string_owned(buf)? }; }
122 if version >= 0 { out.topic_id = crate::primitives::uuid::get_uuid(buf)?; }
123 if version >= 0 { out.partitions = { let n = crate::primitives::array::get_array_len(buf, flex)?; let mut v = Vec::with_capacity(n); for _ in 0..n { v.push(AlterShareGroupOffsetsResponsePartition::decode(buf, version)?); } v }; }
124 if flex {
125 out.unknown_tagged_fields = read_tagged_fields(buf, |_tag, _payload| {
126 Ok(false)
127 })?;
128 }
129 Ok(out)
130 }
131}
132
133#[derive(Debug, Clone, PartialEq, Eq, Default)]
134pub struct AlterShareGroupOffsetsResponsePartition {
135 pub partition_index: i32,
136 pub error_code: i16,
137 pub error_message: Option<String>,
138 pub unknown_tagged_fields: UnknownTaggedFields,
139}
140
141impl Encode for AlterShareGroupOffsetsResponsePartition {
142 fn encode<B: BufMut>(&self, buf: &mut B, version: i16) -> Result<(), ProtocolError> {
143 let flex = version >= 0;
144 if version >= 0 { put_i32(buf, self.partition_index) }
145 if version >= 0 { put_i16(buf, self.error_code) }
146 if version >= 0 { if flex { put_compact_nullable_string(buf, self.error_message.as_deref()) } else { put_nullable_string(buf, self.error_message.as_deref()) } }
147 if flex {
148 let tagged = WriteTaggedFields::new();
149 tagged.write(buf, &self.unknown_tagged_fields);
150 }
151 Ok(())
152 }
153 fn encoded_len(&self, version: i16) -> usize {
154 let flex = version >= 0;
155 let mut n: usize = 0;
156 if version >= 0 { n += 4; }
157 if version >= 0 { n += 2; }
158 if version >= 0 { n += if flex { compact_nullable_string_len(self.error_message.as_deref()) } else { nullable_string_len(self.error_message.as_deref()) }; }
159 if flex {
160 let known_pairs: Vec<(u32, usize)> = Vec::new();
161 n += tagged_fields_len(&known_pairs, &self.unknown_tagged_fields);
162 }
163 n
164 }
165}
166
167impl<'de> Decode<'de> for AlterShareGroupOffsetsResponsePartition {
168 fn decode<B: Buf>(buf: &mut B, version: i16) -> Result<Self, ProtocolError> {
169 let flex = version >= 0;
170 let mut out = Self::default();
171 if version >= 0 { out.partition_index = get_i32(buf)?; }
172 if version >= 0 { out.error_code = get_i16(buf)?; }
173 if version >= 0 { out.error_message = if flex { get_compact_nullable_string_owned(buf)? } else { get_nullable_string_owned(buf)? }; }
174 if flex {
175 out.unknown_tagged_fields = read_tagged_fields(buf, |_tag, _payload| {
176 Ok(false)
177 })?;
178 }
179 Ok(out)
180 }
181}
182
183#[must_use]
186#[allow(unused_comparisons)]
187pub fn default_json(version: i16) -> ::serde_json::Value {
188 let mut obj = ::serde_json::Map::new();
189 obj.insert("throttleTimeMs".to_string(), ::serde_json::json!(0));
190 obj.insert("errorCode".to_string(), ::serde_json::json!(0));
191 obj.insert("errorMessage".to_string(), ::serde_json::Value::Null);
192 obj.insert("responses".to_string(), ::serde_json::Value::Array(vec![]));
193 ::serde_json::Value::Object(obj)
194}