kafka_api/schemata/
sync_group_request.rs1use byteorder::ReadBytesExt;
16
17use crate::codec::*;
18use crate::IoResult;
19
20#[derive(Debug, Default, Clone)]
32pub struct SyncGroupRequest {
33 pub group_id: String,
35 pub generation_id: i32,
37 pub member_id: String,
39 pub group_instance_id: Option<String>,
41 pub protocol_type: Option<String>,
43 pub protocol_name: Option<String>,
45 pub assignments: Vec<SyncGroupRequestAssignment>,
47 pub unknown_tagged_fields: Vec<RawTaggedField>,
49}
50
51impl Decodable for SyncGroupRequest {
52 fn read<B: ReadBytesExt>(buf: &mut B, version: i16) -> IoResult<Self> {
53 let mut this = SyncGroupRequest {
54 group_id: NullableString(version >= 4)
55 .decode(buf)?
56 .ok_or_else(|| err_decode_message_null("group_id"))?,
57 generation_id: Int32.decode(buf)?,
58 member_id: NullableString(version >= 4)
59 .decode(buf)?
60 .ok_or_else(|| err_decode_message_null("member_id"))?,
61 ..Default::default()
62 };
63 if version >= 3 {
64 this.group_instance_id = NullableString(version >= 4).decode(buf)?;
65 }
66 if version >= 5 {
67 this.protocol_type = NullableString(true).decode(buf)?;
68 this.protocol_name = NullableString(true).decode(buf)?;
69 }
70 this.assignments = NullableArray(Struct(version), version >= 4)
71 .decode(buf)?
72 .ok_or_else(|| err_decode_message_null("assignments"))?;
73 if version >= 4 {
74 this.unknown_tagged_fields = RawTaggedFieldList.decode(buf)?;
75 }
76 Ok(this)
77 }
78}
79
80#[derive(Debug, Default, Clone)]
81pub struct SyncGroupRequestAssignment {
82 pub member_id: String,
84 pub assignment: Vec<u8>,
86 pub unknown_tagged_fields: Vec<RawTaggedField>,
88}
89
90impl Decodable for SyncGroupRequestAssignment {
91 fn read<B: ReadBytesExt>(buf: &mut B, version: i16) -> IoResult<Self> {
92 if version > 5 {
93 Err(err_decode_message_unsupported(
94 version,
95 "SyncGroupRequestAssignment",
96 ))?
97 }
98 let mut this = SyncGroupRequestAssignment {
99 member_id: NullableString(version >= 4)
100 .decode(buf)?
101 .ok_or_else(|| err_decode_message_null("member_id"))?,
102 assignment: NullableBytes(version >= 4)
103 .decode(buf)?
104 .ok_or_else(|| err_decode_message_null("assignment"))?,
105 ..Default::default()
106 };
107 if version >= 4 {
108 this.unknown_tagged_fields = RawTaggedFieldList.decode(buf)?;
109 }
110 Ok(this)
111 }
112}