kafka_api/schemata/
offset_fetch_request.rs1use byteorder::ReadBytesExt;
16
17use crate::codec::*;
18use crate::IoResult;
19
20#[derive(Debug, Default, Clone)]
38pub struct OffsetFetchRequest {
39 pub group_id: String,
41 pub topics: Vec<OffsetFetchRequestTopic>,
43 pub groups: Vec<OffsetFetchRequestGroup>,
45 pub require_stable: bool,
48 pub unknown_tagged_fields: Vec<RawTaggedField>,
50}
51
52impl Decodable for OffsetFetchRequest {
53 fn read<B: ReadBytesExt>(buf: &mut B, version: i16) -> IoResult<Self> {
54 let mut this = OffsetFetchRequest::default();
55 if version <= 7 {
56 this.group_id = NullableString(version >= 6)
57 .decode(buf)?
58 .ok_or_else(|| err_decode_message_null("groups"))?;
59 this.topics = NullableArray(Struct(version), version >= 6)
60 .decode(buf)?
61 .or_else(|| if version >= 2 { Some(vec![]) } else { None })
62 .ok_or_else(|| err_decode_message_null("topics"))?;
63 }
64 if version >= 8 {
65 this.groups = NullableArray(Struct(version), true)
66 .decode(buf)?
67 .ok_or_else(|| err_decode_message_null("groups"))?;
68 }
69 if version >= 7 {
70 this.require_stable = Bool.decode(buf)?;
71 }
72 if version >= 6 {
73 this.unknown_tagged_fields = RawTaggedFieldList.decode(buf)?;
74 }
75 Ok(this)
76 }
77}
78
79#[derive(Debug, Default, Clone)]
80pub struct OffsetFetchRequestTopic {
81 pub name: String,
83 pub partition_indexes: Vec<i32>,
85 pub unknown_tagged_fields: Vec<RawTaggedField>,
87}
88
89impl Decodable for OffsetFetchRequestTopic {
90 fn read<B: ReadBytesExt>(buf: &mut B, version: i16) -> IoResult<Self> {
91 let mut this = OffsetFetchRequestTopic {
92 name: NullableString(version >= 6)
93 .decode(buf)?
94 .ok_or_else(|| err_decode_message_null("name"))?,
95 partition_indexes: NullableArray(Int32, version >= 6)
96 .decode(buf)?
97 .ok_or_else(|| err_decode_message_null("partition_indexes"))?,
98 ..Default::default()
99 };
100 if version >= 6 {
101 this.unknown_tagged_fields = RawTaggedFieldList.decode(buf)?;
102 }
103 Ok(this)
104 }
105}
106
107#[derive(Debug, Default, Clone)]
108pub struct OffsetFetchRequestGroup {
109 pub group_id: String,
111 pub topics: Vec<OffsetFetchRequestTopic>,
113 pub unknown_tagged_fields: Vec<RawTaggedField>,
115}
116
117impl Decodable for OffsetFetchRequestGroup {
118 fn read<B: ReadBytesExt>(buf: &mut B, version: i16) -> IoResult<Self> {
119 if version > 8 {
120 Err(err_decode_message_unsupported(
121 version,
122 "OffsetFetchRequestGroup",
123 ))?
124 }
125 let mut this = OffsetFetchRequestGroup {
126 group_id: NullableString(true)
127 .decode(buf)?
128 .ok_or_else(|| err_decode_message_null("group_id"))?,
129 topics: NullableArray(Struct(version), true)
130 .decode(buf)?
131 .unwrap_or_default(),
132 ..Default::default()
133 };
134 if version >= 6 {
135 this.unknown_tagged_fields = RawTaggedFieldList.decode(buf)?;
136 }
137 Ok(this)
138 }
139}