1use bytes::BufMut;
4
5use crate::primitives::fixed::{get_bool, get_i16, get_i32, get_i8, put_bool, put_i16, put_i32};
6use crate::primitives::string_bytes::{
7 compact_nullable_string_len, compact_string_len, nullable_string_len,
8 put_compact_nullable_string, put_compact_string, put_nullable_string, put_string,
9 string_len,
10};
11use crate::primitives::string_bytes_borrowed::{
12 get_compact_nullable_string_borrowed, get_compact_string_borrowed,
13 get_nullable_string_borrowed, get_string_borrowed,
14};
15use crate::tagged_fields::{read_tagged_fields, tagged_fields_len, WriteTaggedFields};
16use crate::{DecodeBorrow, Encode, ProtocolError, UnknownTaggedFields};
17
18pub const API_KEY: i16 = 89;
19pub const MIN_VERSION: i16 = 0;
20pub const MAX_VERSION: i16 = 0;
21pub const FLEXIBLE_MIN: i16 = 0;
22
23#[inline]
24fn is_flexible(version: i16) -> bool { version >= FLEXIBLE_MIN }
25
26#[derive(Debug, Clone, PartialEq, Eq)]
27pub struct StreamsGroupDescribeResponse<'a> {
28 pub throttle_time_ms: i32,
29 pub groups: Vec<DescribedGroup<'a>>,
30 pub unknown_tagged_fields: UnknownTaggedFields,
31}
32
33impl<'a> Default for StreamsGroupDescribeResponse<'a> {
34 fn default() -> Self {
35 Self {
36 throttle_time_ms: 0i32,
37 groups: Vec::new(),
38 unknown_tagged_fields: Default::default(),
39 }
40 }
41}
42
43impl<'a> StreamsGroupDescribeResponse<'a> {
44 pub fn to_owned(&self) -> crate::owned::streams_group_describe_response::StreamsGroupDescribeResponse {
45 crate::owned::streams_group_describe_response::StreamsGroupDescribeResponse {
46 throttle_time_ms: (self.throttle_time_ms),
47 groups: (self.groups).iter().map(|it| it.to_owned()).collect(),
48 unknown_tagged_fields: self.unknown_tagged_fields.clone(),
49 }
50 }
51}
52
53impl<'a> Encode for StreamsGroupDescribeResponse<'a> {
54 fn encode<B: BufMut>(&self, buf: &mut B, version: i16) -> Result<(), ProtocolError> {
55 if !(MIN_VERSION..=MAX_VERSION).contains(&version) {
56 return Err(ProtocolError::UnsupportedVersion { api_key: API_KEY, version });
57 }
58 let flex = is_flexible(version);
59 if version >= 0 { put_i32(buf, self.throttle_time_ms) }
60 if version >= 0 { { crate::primitives::array::put_array_len(buf, (self.groups).len(), flex); for it in &self.groups { it.encode(buf, version)?; } } }
61 if flex {
62 let tagged = WriteTaggedFields::new();
63 tagged.write(buf, &self.unknown_tagged_fields);
64 }
65 Ok(())
66 }
67 fn encoded_len(&self, version: i16) -> usize {
68 let flex = is_flexible(version);
69 let mut n: usize = 0;
70 if version >= 0 { n += 4; }
71 if version >= 0 { n += { let prefix = crate::primitives::array::array_len_prefix_len((self.groups).len(), flex); let body: usize = (self.groups).iter().map(|it| it.encoded_len(version)).sum(); prefix + body }; }
72 if flex {
73 let known_pairs: Vec<(u32, usize)> = Vec::new();
74 n += tagged_fields_len(&known_pairs, &self.unknown_tagged_fields);
75 }
76 n
77 }
78}
79
80impl<'de> DecodeBorrow<'de> for StreamsGroupDescribeResponse<'de> {
81 fn decode_borrow(buf: &mut &'de [u8], version: i16) -> Result<Self, ProtocolError> {
82 if !(MIN_VERSION..=MAX_VERSION).contains(&version) {
83 return Err(ProtocolError::UnsupportedVersion { api_key: API_KEY, version });
84 }
85 let flex = is_flexible(version);
86 let mut out = Self::default();
87 if version >= 0 { out.throttle_time_ms = get_i32(buf)?; }
88 if version >= 0 { out.groups = { let n = crate::primitives::array::get_array_len(buf, flex)?; let mut v = Vec::with_capacity(n); for _ in 0..n { v.push(DescribedGroup::decode_borrow(buf, version)?); } v }; }
89 if flex {
90 out.unknown_tagged_fields = read_tagged_fields(buf, |_tag, _payload| {
91 Ok(false)
92 })?;
93 }
94 Ok(out)
95 }
96}
97
98#[derive(Debug, Clone, PartialEq, Eq)]
99pub struct DescribedGroup<'a> {
100 pub error_code: i16,
101 pub error_message: Option<&'a str>,
102 pub group_id: &'a str,
103 pub group_state: &'a str,
104 pub group_epoch: i32,
105 pub assignment_epoch: i32,
106 pub topology: Option<Topology<'a>>,
107 pub members: Vec<Member<'a>>,
108 pub authorized_operations: i32,
109 pub unknown_tagged_fields: UnknownTaggedFields,
110}
111
112impl<'a> Default for DescribedGroup<'a> {
113 fn default() -> Self {
114 Self {
115 error_code: 0i16,
116 error_message: None,
117 group_id: "",
118 group_state: "",
119 group_epoch: 0i32,
120 assignment_epoch: 0i32,
121 topology: None,
122 members: Vec::new(),
123 authorized_operations: -2_147_483_648i32,
124 unknown_tagged_fields: Default::default(),
125 }
126 }
127}
128
129impl<'a> DescribedGroup<'a> {
130 pub fn to_owned(&self) -> crate::owned::streams_group_describe_response::DescribedGroup {
131 crate::owned::streams_group_describe_response::DescribedGroup {
132 error_code: (self.error_code),
133 error_message: (self.error_message).map(|s| s.to_string()),
134 group_id: (self.group_id).to_string(),
135 group_state: (self.group_state).to_string(),
136 group_epoch: (self.group_epoch),
137 assignment_epoch: (self.assignment_epoch),
138 topology: (self.topology).as_ref().map(|v| v.to_owned()),
139 members: (self.members).iter().map(|it| it.to_owned()).collect(),
140 authorized_operations: (self.authorized_operations),
141 unknown_tagged_fields: self.unknown_tagged_fields.clone(),
142 }
143 }
144}
145
146impl<'a> Encode for DescribedGroup<'a> {
147 fn encode<B: BufMut>(&self, buf: &mut B, version: i16) -> Result<(), ProtocolError> {
148 let flex = version >= 0;
149 if version >= 0 { put_i16(buf, self.error_code) }
150 if version >= 0 { if flex { put_compact_nullable_string(buf, self.error_message) } else { put_nullable_string(buf, self.error_message) } }
151 if version >= 0 { if flex { put_compact_string(buf, self.group_id) } else { put_string(buf, self.group_id) } }
152 if version >= 0 { if flex { put_compact_string(buf, self.group_state) } else { put_string(buf, self.group_state) } }
153 if version >= 0 { put_i32(buf, self.group_epoch) }
154 if version >= 0 { put_i32(buf, self.assignment_epoch) }
155 if version >= 0 { match &self.topology { None => { buf.put_i8(-1); }, Some(v) => { buf.put_i8(1); v.encode(buf, version)?; } } }
156 if version >= 0 { { crate::primitives::array::put_array_len(buf, (self.members).len(), flex); for it in &self.members { it.encode(buf, version)?; } } }
157 if version >= 0 { put_i32(buf, self.authorized_operations) }
158 if flex {
159 let tagged = WriteTaggedFields::new();
160 tagged.write(buf, &self.unknown_tagged_fields);
161 }
162 Ok(())
163 }
164 fn encoded_len(&self, version: i16) -> usize {
165 let flex = version >= 0;
166 let mut n: usize = 0;
167 if version >= 0 { n += 2; }
168 if version >= 0 { n += if flex { compact_nullable_string_len(self.error_message) } else { nullable_string_len(self.error_message) }; }
169 if version >= 0 { n += if flex { compact_string_len(self.group_id) } else { string_len(self.group_id) }; }
170 if version >= 0 { n += if flex { compact_string_len(self.group_state) } else { string_len(self.group_state) }; }
171 if version >= 0 { n += 4; }
172 if version >= 0 { n += 4; }
173 if version >= 0 { n += 1 + self.topology.as_ref().map_or(0, |v| v.encoded_len(version)); }
174 if version >= 0 { n += { let prefix = crate::primitives::array::array_len_prefix_len((self.members).len(), flex); let body: usize = (self.members).iter().map(|it| it.encoded_len(version)).sum(); prefix + body }; }
175 if version >= 0 { n += 4; }
176 if flex {
177 let known_pairs: Vec<(u32, usize)> = Vec::new();
178 n += tagged_fields_len(&known_pairs, &self.unknown_tagged_fields);
179 }
180 n
181 }
182}
183
184impl<'de> DecodeBorrow<'de> for DescribedGroup<'de> {
185 fn decode_borrow(buf: &mut &'de [u8], version: i16) -> Result<Self, ProtocolError> {
186 let flex = version >= 0;
187 let mut out = Self::default();
188 if version >= 0 { out.error_code = get_i16(buf)?; }
189 if version >= 0 { out.error_message = if flex { get_compact_nullable_string_borrowed(buf)? } else { get_nullable_string_borrowed(buf)? }; }
190 if version >= 0 { out.group_id = if flex { get_compact_string_borrowed(buf)? } else { get_string_borrowed(buf)? }; }
191 if version >= 0 { out.group_state = if flex { get_compact_string_borrowed(buf)? } else { get_string_borrowed(buf)? }; }
192 if version >= 0 { out.group_epoch = get_i32(buf)?; }
193 if version >= 0 { out.assignment_epoch = get_i32(buf)?; }
194 if version >= 0 { out.topology = if get_i8(buf)? < 0 { None } else { Some(Topology::decode_borrow(buf, version)?) }; }
195 if version >= 0 { out.members = { let n = crate::primitives::array::get_array_len(buf, flex)?; let mut v = Vec::with_capacity(n); for _ in 0..n { v.push(Member::decode_borrow(buf, version)?); } v }; }
196 if version >= 0 { out.authorized_operations = get_i32(buf)?; }
197 if flex {
198 out.unknown_tagged_fields = read_tagged_fields(buf, |_tag, _payload| {
199 Ok(false)
200 })?;
201 }
202 Ok(out)
203 }
204}
205
206#[derive(Debug, Clone, PartialEq, Eq)]
207pub struct Topology<'a> {
208 pub epoch: i32,
209 pub subtopologies: Option<Vec<Subtopology<'a>>>,
210 pub unknown_tagged_fields: UnknownTaggedFields,
211}
212
213impl<'a> Default for Topology<'a> {
214 fn default() -> Self {
215 Self {
216 epoch: 0i32,
217 subtopologies: None,
218 unknown_tagged_fields: Default::default(),
219 }
220 }
221}
222
223impl<'a> Topology<'a> {
224 pub fn to_owned(&self) -> crate::owned::streams_group_describe_response::Topology {
225 crate::owned::streams_group_describe_response::Topology {
226 epoch: (self.epoch),
227 subtopologies: (self.subtopologies).as_ref().map(|v| v.iter().map(|it| it.to_owned()).collect()),
228 unknown_tagged_fields: self.unknown_tagged_fields.clone(),
229 }
230 }
231}
232
233impl<'a> Encode for Topology<'a> {
234 fn encode<B: BufMut>(&self, buf: &mut B, version: i16) -> Result<(), ProtocolError> {
235 let flex = version >= 0;
236 if version >= 0 { put_i32(buf, self.epoch) }
237 if version >= 0 { { let len = (self.subtopologies).as_ref().map(Vec::len); crate::primitives::array::put_nullable_array_len(buf, len, flex); if let Some(v) = &self.subtopologies { for it in v { it.encode(buf, version)?; } } } }
238 if flex {
239 let tagged = WriteTaggedFields::new();
240 tagged.write(buf, &self.unknown_tagged_fields);
241 }
242 Ok(())
243 }
244 fn encoded_len(&self, version: i16) -> usize {
245 let flex = version >= 0;
246 let mut n: usize = 0;
247 if version >= 0 { n += 4; }
248 if version >= 0 { n += { let opt: Option<&Vec<_>> = (self.subtopologies).as_ref(); let prefix = crate::primitives::array::nullable_array_len_prefix_len(opt.map(|v| v.len()), flex); let body: usize = opt.map_or(0, |v| v.iter().map(|it| it.encoded_len(version)).sum()); prefix + body }; }
249 if flex {
250 let known_pairs: Vec<(u32, usize)> = Vec::new();
251 n += tagged_fields_len(&known_pairs, &self.unknown_tagged_fields);
252 }
253 n
254 }
255}
256
257impl<'de> DecodeBorrow<'de> for Topology<'de> {
258 fn decode_borrow(buf: &mut &'de [u8], version: i16) -> Result<Self, ProtocolError> {
259 let flex = version >= 0;
260 let mut out = Self::default();
261 if version >= 0 { out.epoch = get_i32(buf)?; }
262 if version >= 0 { out.subtopologies = { let opt = crate::primitives::array::get_nullable_array_len(buf, flex)?; match opt { None => None, Some(n) => { let mut v = Vec::with_capacity(n); for _ in 0..n { v.push(Subtopology::decode_borrow(buf, version)?); } Some(v) } } }; }
263 if flex {
264 out.unknown_tagged_fields = read_tagged_fields(buf, |_tag, _payload| {
265 Ok(false)
266 })?;
267 }
268 Ok(out)
269 }
270}
271
272#[derive(Debug, Clone, PartialEq, Eq)]
273pub struct Subtopology<'a> {
274 pub subtopology_id: &'a str,
275 pub source_topics: Vec<&'a str>,
276 pub repartition_sink_topics: Vec<&'a str>,
277 pub state_changelog_topics: Vec<super::common::topic_info::TopicInfo<'a>>,
278 pub repartition_source_topics: Vec<super::common::topic_info::TopicInfo<'a>>,
279 pub unknown_tagged_fields: UnknownTaggedFields,
280}
281
282impl<'a> Default for Subtopology<'a> {
283 fn default() -> Self {
284 Self {
285 subtopology_id: "",
286 source_topics: Vec::new(),
287 repartition_sink_topics: Vec::new(),
288 state_changelog_topics: Vec::new(),
289 repartition_source_topics: Vec::new(),
290 unknown_tagged_fields: Default::default(),
291 }
292 }
293}
294
295impl<'a> Subtopology<'a> {
296 pub fn to_owned(&self) -> crate::owned::streams_group_describe_response::Subtopology {
297 crate::owned::streams_group_describe_response::Subtopology {
298 subtopology_id: (self.subtopology_id).to_string(),
299 source_topics: (self.source_topics).iter().map(|s| s.to_string()).collect(),
300 repartition_sink_topics: (self.repartition_sink_topics).iter().map(|s| s.to_string()).collect(),
301 state_changelog_topics: (self.state_changelog_topics).iter().map(|it| it.to_owned()).collect(),
302 repartition_source_topics: (self.repartition_source_topics).iter().map(|it| it.to_owned()).collect(),
303 unknown_tagged_fields: self.unknown_tagged_fields.clone(),
304 }
305 }
306}
307
308impl<'a> Encode for Subtopology<'a> {
309 fn encode<B: BufMut>(&self, buf: &mut B, version: i16) -> Result<(), ProtocolError> {
310 let flex = version >= 0;
311 if version >= 0 { if flex { put_compact_string(buf, self.subtopology_id) } else { put_string(buf, self.subtopology_id) } }
312 if version >= 0 { { crate::primitives::array::put_array_len(buf, (self.source_topics).len(), flex); for it in &self.source_topics { if flex { put_compact_string(buf, *it) } else { put_string(buf, *it) }; } } }
313 if version >= 0 { { crate::primitives::array::put_array_len(buf, (self.repartition_sink_topics).len(), flex); for it in &self.repartition_sink_topics { if flex { put_compact_string(buf, *it) } else { put_string(buf, *it) }; } } }
314 if version >= 0 { { crate::primitives::array::put_array_len(buf, (self.state_changelog_topics).len(), flex); for it in &self.state_changelog_topics { it.encode(buf, version)?; } } }
315 if version >= 0 { { crate::primitives::array::put_array_len(buf, (self.repartition_source_topics).len(), flex); for it in &self.repartition_source_topics { it.encode(buf, version)?; } } }
316 if flex {
317 let tagged = WriteTaggedFields::new();
318 tagged.write(buf, &self.unknown_tagged_fields);
319 }
320 Ok(())
321 }
322 fn encoded_len(&self, version: i16) -> usize {
323 let flex = version >= 0;
324 let mut n: usize = 0;
325 if version >= 0 { n += if flex { compact_string_len(self.subtopology_id) } else { string_len(self.subtopology_id) }; }
326 if version >= 0 { n += { let prefix = crate::primitives::array::array_len_prefix_len((self.source_topics).len(), flex); let body: usize = (self.source_topics).iter().map(|it| if flex { compact_string_len(*it) } else { string_len(*it) }).sum(); prefix + body }; }
327 if version >= 0 { n += { let prefix = crate::primitives::array::array_len_prefix_len((self.repartition_sink_topics).len(), flex); let body: usize = (self.repartition_sink_topics).iter().map(|it| if flex { compact_string_len(*it) } else { string_len(*it) }).sum(); prefix + body }; }
328 if version >= 0 { n += { let prefix = crate::primitives::array::array_len_prefix_len((self.state_changelog_topics).len(), flex); let body: usize = (self.state_changelog_topics).iter().map(|it| it.encoded_len(version)).sum(); prefix + body }; }
329 if version >= 0 { n += { let prefix = crate::primitives::array::array_len_prefix_len((self.repartition_source_topics).len(), flex); let body: usize = (self.repartition_source_topics).iter().map(|it| it.encoded_len(version)).sum(); prefix + body }; }
330 if flex {
331 let known_pairs: Vec<(u32, usize)> = Vec::new();
332 n += tagged_fields_len(&known_pairs, &self.unknown_tagged_fields);
333 }
334 n
335 }
336}
337
338impl<'de> DecodeBorrow<'de> for Subtopology<'de> {
339 fn decode_borrow(buf: &mut &'de [u8], version: i16) -> Result<Self, ProtocolError> {
340 let flex = version >= 0;
341 let mut out = Self::default();
342 if version >= 0 { out.subtopology_id = if flex { get_compact_string_borrowed(buf)? } else { get_string_borrowed(buf)? }; }
343 if version >= 0 { out.source_topics = { let n = crate::primitives::array::get_array_len(buf, flex)?; let mut v = Vec::with_capacity(n); for _ in 0..n { v.push(if flex { get_compact_string_borrowed(buf)? } else { get_string_borrowed(buf)? }); } v }; }
344 if version >= 0 { out.repartition_sink_topics = { let n = crate::primitives::array::get_array_len(buf, flex)?; let mut v = Vec::with_capacity(n); for _ in 0..n { v.push(if flex { get_compact_string_borrowed(buf)? } else { get_string_borrowed(buf)? }); } v }; }
345 if version >= 0 { out.state_changelog_topics = { let n = crate::primitives::array::get_array_len(buf, flex)?; let mut v = Vec::with_capacity(n); for _ in 0..n { v.push(super::common::topic_info::TopicInfo::decode_borrow(buf, version)?); } v }; }
346 if version >= 0 { out.repartition_source_topics = { let n = crate::primitives::array::get_array_len(buf, flex)?; let mut v = Vec::with_capacity(n); for _ in 0..n { v.push(super::common::topic_info::TopicInfo::decode_borrow(buf, version)?); } v }; }
347 if flex {
348 out.unknown_tagged_fields = read_tagged_fields(buf, |_tag, _payload| {
349 Ok(false)
350 })?;
351 }
352 Ok(out)
353 }
354}
355
356#[derive(Debug, Clone, PartialEq, Eq)]
357pub struct Member<'a> {
358 pub member_id: &'a str,
359 pub member_epoch: i32,
360 pub instance_id: Option<&'a str>,
361 pub rack_id: Option<&'a str>,
362 pub client_id: &'a str,
363 pub client_host: &'a str,
364 pub topology_epoch: i32,
365 pub process_id: &'a str,
366 pub user_endpoint: Option<super::common::endpoint::Endpoint<'a>>,
367 pub client_tags: Vec<super::common::key_value::KeyValue<'a>>,
368 pub task_offsets: Vec<super::common::task_offset::TaskOffset<'a>>,
369 pub task_end_offsets: Vec<super::common::task_offset::TaskOffset<'a>>,
370 pub assignment: super::common::assignment::Assignment<'a>,
371 pub target_assignment: super::common::assignment::Assignment<'a>,
372 pub is_classic: bool,
373 pub unknown_tagged_fields: UnknownTaggedFields,
374}
375
376impl<'a> Default for Member<'a> {
377 fn default() -> Self {
378 Self {
379 member_id: "",
380 member_epoch: 0i32,
381 instance_id: None,
382 rack_id: None,
383 client_id: "",
384 client_host: "",
385 topology_epoch: 0i32,
386 process_id: "",
387 user_endpoint: None,
388 client_tags: Vec::new(),
389 task_offsets: Vec::new(),
390 task_end_offsets: Vec::new(),
391 assignment: Default::default(),
392 target_assignment: Default::default(),
393 is_classic: false,
394 unknown_tagged_fields: Default::default(),
395 }
396 }
397}
398
399impl<'a> Member<'a> {
400 pub fn to_owned(&self) -> crate::owned::streams_group_describe_response::Member {
401 crate::owned::streams_group_describe_response::Member {
402 member_id: (self.member_id).to_string(),
403 member_epoch: (self.member_epoch),
404 instance_id: (self.instance_id).map(|s| s.to_string()),
405 rack_id: (self.rack_id).map(|s| s.to_string()),
406 client_id: (self.client_id).to_string(),
407 client_host: (self.client_host).to_string(),
408 topology_epoch: (self.topology_epoch),
409 process_id: (self.process_id).to_string(),
410 user_endpoint: (self.user_endpoint).as_ref().map(|v| v.to_owned()),
411 client_tags: (self.client_tags).iter().map(|it| it.to_owned()).collect(),
412 task_offsets: (self.task_offsets).iter().map(|it| it.to_owned()).collect(),
413 task_end_offsets: (self.task_end_offsets).iter().map(|it| it.to_owned()).collect(),
414 assignment: (self.assignment).to_owned(),
415 target_assignment: (self.target_assignment).to_owned(),
416 is_classic: (self.is_classic),
417 unknown_tagged_fields: self.unknown_tagged_fields.clone(),
418 }
419 }
420}
421
422impl<'a> Encode for Member<'a> {
423 fn encode<B: BufMut>(&self, buf: &mut B, version: i16) -> Result<(), ProtocolError> {
424 let flex = version >= 0;
425 if version >= 0 { if flex { put_compact_string(buf, self.member_id) } else { put_string(buf, self.member_id) } }
426 if version >= 0 { put_i32(buf, self.member_epoch) }
427 if version >= 0 { if flex { put_compact_nullable_string(buf, self.instance_id) } else { put_nullable_string(buf, self.instance_id) } }
428 if version >= 0 { if flex { put_compact_nullable_string(buf, self.rack_id) } else { put_nullable_string(buf, self.rack_id) } }
429 if version >= 0 { if flex { put_compact_string(buf, self.client_id) } else { put_string(buf, self.client_id) } }
430 if version >= 0 { if flex { put_compact_string(buf, self.client_host) } else { put_string(buf, self.client_host) } }
431 if version >= 0 { put_i32(buf, self.topology_epoch) }
432 if version >= 0 { if flex { put_compact_string(buf, self.process_id) } else { put_string(buf, self.process_id) } }
433 if version >= 0 { match &self.user_endpoint { None => { buf.put_i8(-1); }, Some(v) => { buf.put_i8(1); v.encode(buf, version)?; } } }
434 if version >= 0 { { crate::primitives::array::put_array_len(buf, (self.client_tags).len(), flex); for it in &self.client_tags { it.encode(buf, version)?; } } }
435 if version >= 0 { { crate::primitives::array::put_array_len(buf, (self.task_offsets).len(), flex); for it in &self.task_offsets { it.encode(buf, version)?; } } }
436 if version >= 0 { { crate::primitives::array::put_array_len(buf, (self.task_end_offsets).len(), flex); for it in &self.task_end_offsets { it.encode(buf, version)?; } } }
437 if version >= 0 { self.assignment.encode(buf, version)? }
438 if version >= 0 { self.target_assignment.encode(buf, version)? }
439 if version >= 0 { put_bool(buf, self.is_classic) }
440 if flex {
441 let tagged = WriteTaggedFields::new();
442 tagged.write(buf, &self.unknown_tagged_fields);
443 }
444 Ok(())
445 }
446 fn encoded_len(&self, version: i16) -> usize {
447 let flex = version >= 0;
448 let mut n: usize = 0;
449 if version >= 0 { n += if flex { compact_string_len(self.member_id) } else { string_len(self.member_id) }; }
450 if version >= 0 { n += 4; }
451 if version >= 0 { n += if flex { compact_nullable_string_len(self.instance_id) } else { nullable_string_len(self.instance_id) }; }
452 if version >= 0 { n += if flex { compact_nullable_string_len(self.rack_id) } else { nullable_string_len(self.rack_id) }; }
453 if version >= 0 { n += if flex { compact_string_len(self.client_id) } else { string_len(self.client_id) }; }
454 if version >= 0 { n += if flex { compact_string_len(self.client_host) } else { string_len(self.client_host) }; }
455 if version >= 0 { n += 4; }
456 if version >= 0 { n += if flex { compact_string_len(self.process_id) } else { string_len(self.process_id) }; }
457 if version >= 0 { n += 1 + self.user_endpoint.as_ref().map_or(0, |v| v.encoded_len(version)); }
458 if version >= 0 { n += { let prefix = crate::primitives::array::array_len_prefix_len((self.client_tags).len(), flex); let body: usize = (self.client_tags).iter().map(|it| it.encoded_len(version)).sum(); prefix + body }; }
459 if version >= 0 { n += { let prefix = crate::primitives::array::array_len_prefix_len((self.task_offsets).len(), flex); let body: usize = (self.task_offsets).iter().map(|it| it.encoded_len(version)).sum(); prefix + body }; }
460 if version >= 0 { n += { let prefix = crate::primitives::array::array_len_prefix_len((self.task_end_offsets).len(), flex); let body: usize = (self.task_end_offsets).iter().map(|it| it.encoded_len(version)).sum(); prefix + body }; }
461 if version >= 0 { n += self.assignment.encoded_len(version); }
462 if version >= 0 { n += self.target_assignment.encoded_len(version); }
463 if version >= 0 { n += 1; }
464 if flex {
465 let known_pairs: Vec<(u32, usize)> = Vec::new();
466 n += tagged_fields_len(&known_pairs, &self.unknown_tagged_fields);
467 }
468 n
469 }
470}
471
472impl<'de> DecodeBorrow<'de> for Member<'de> {
473 fn decode_borrow(buf: &mut &'de [u8], version: i16) -> Result<Self, ProtocolError> {
474 let flex = version >= 0;
475 let mut out = Self::default();
476 if version >= 0 { out.member_id = if flex { get_compact_string_borrowed(buf)? } else { get_string_borrowed(buf)? }; }
477 if version >= 0 { out.member_epoch = get_i32(buf)?; }
478 if version >= 0 { out.instance_id = if flex { get_compact_nullable_string_borrowed(buf)? } else { get_nullable_string_borrowed(buf)? }; }
479 if version >= 0 { out.rack_id = if flex { get_compact_nullable_string_borrowed(buf)? } else { get_nullable_string_borrowed(buf)? }; }
480 if version >= 0 { out.client_id = if flex { get_compact_string_borrowed(buf)? } else { get_string_borrowed(buf)? }; }
481 if version >= 0 { out.client_host = if flex { get_compact_string_borrowed(buf)? } else { get_string_borrowed(buf)? }; }
482 if version >= 0 { out.topology_epoch = get_i32(buf)?; }
483 if version >= 0 { out.process_id = if flex { get_compact_string_borrowed(buf)? } else { get_string_borrowed(buf)? }; }
484 if version >= 0 { out.user_endpoint = if get_i8(buf)? < 0 { None } else { Some(super::common::endpoint::Endpoint::decode_borrow(buf, version)?) }; }
485 if version >= 0 { out.client_tags = { let n = crate::primitives::array::get_array_len(buf, flex)?; let mut v = Vec::with_capacity(n); for _ in 0..n { v.push(super::common::key_value::KeyValue::decode_borrow(buf, version)?); } v }; }
486 if version >= 0 { out.task_offsets = { let n = crate::primitives::array::get_array_len(buf, flex)?; let mut v = Vec::with_capacity(n); for _ in 0..n { v.push(super::common::task_offset::TaskOffset::decode_borrow(buf, version)?); } v }; }
487 if version >= 0 { out.task_end_offsets = { let n = crate::primitives::array::get_array_len(buf, flex)?; let mut v = Vec::with_capacity(n); for _ in 0..n { v.push(super::common::task_offset::TaskOffset::decode_borrow(buf, version)?); } v }; }
488 if version >= 0 { out.assignment = super::common::assignment::Assignment::decode_borrow(buf, version)?; }
489 if version >= 0 { out.target_assignment = super::common::assignment::Assignment::decode_borrow(buf, version)?; }
490 if version >= 0 { out.is_classic = get_bool(buf)?; }
491 if flex {
492 out.unknown_tagged_fields = read_tagged_fields(buf, |_tag, _payload| {
493 Ok(false)
494 })?;
495 }
496 Ok(out)
497 }
498}