#![allow(
missing_docs,
clippy::all,
clippy::pedantic,
clippy::nursery,
clippy::arithmetic_side_effects,
reason = "Generated protocol modules mirror Kafka's schema shape and intentionally trade \
hand-written lint style for reproducible wire-code output."
)]
use bytes::{Bytes, BytesMut};
use crate::*;
#[derive(Debug, Clone, PartialEq)]
pub struct ShareGroupHeartbeatResponseData {
pub throttle_time_ms: i32,
pub error_code: i16,
pub error_message: Option<KafkaString>,
pub member_id: Option<KafkaString>,
pub member_epoch: i32,
pub heartbeat_interval_ms: i32,
pub assignment: Option<Box<Assignment>>,
pub _unknown_tagged_fields: Vec<RawTaggedField>,
}
impl Default for ShareGroupHeartbeatResponseData {
fn default() -> Self {
Self {
throttle_time_ms: 0_i32,
error_code: 0_i16,
error_message: None,
member_id: None,
member_epoch: 0_i32,
heartbeat_interval_ms: 0_i32,
assignment: None,
_unknown_tagged_fields: Vec::new(),
}
}
}
impl ShareGroupHeartbeatResponseData {
pub fn with_throttle_time_ms(mut self, value: i32) -> Self {
self.throttle_time_ms = value;
self
}
pub fn with_error_code(mut self, value: i16) -> Self {
self.error_code = value;
self
}
pub fn with_error_message(mut self, value: Option<KafkaString>) -> Self {
self.error_message = value;
self
}
pub fn with_member_id(mut self, value: Option<KafkaString>) -> Self {
self.member_id = value;
self
}
pub fn with_member_epoch(mut self, value: i32) -> Self {
self.member_epoch = value;
self
}
pub fn with_heartbeat_interval_ms(mut self, value: i32) -> Self {
self.heartbeat_interval_ms = value;
self
}
pub fn with_assignment(mut self, value: Option<Box<Assignment>>) -> Self {
self.assignment = value;
self
}
pub fn read(buf: &mut Bytes, version: i16) -> Result<Self> {
if version < 1 || version > 1 {
return Err(UnsupportedVersion::new(76, version).into());
}
let throttle_time_ms;
let error_code;
let error_message;
let member_id;
let member_epoch;
let heartbeat_interval_ms;
let assignment;
let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
throttle_time_ms = read_i32(buf)?;
error_code = read_i16(buf)?;
error_message = read_compact_nullable_string(buf)?;
member_id = read_compact_nullable_string(buf)?;
member_epoch = read_i32(buf)?;
heartbeat_interval_ms = read_i32(buf)?;
assignment = {
let marker = read_i8(buf)?;
if marker < 0 {
None
} else {
Some(Box::new(Assignment::read(buf, version)?))
}
};
let tagged_fields = read_tagged_fields(buf)?;
for field in &tagged_fields {
match field.tag {
_ => {
_unknown_tagged_fields.push(field.clone());
},
}
}
Ok(Self {
throttle_time_ms,
error_code,
error_message,
member_id,
member_epoch,
heartbeat_interval_ms,
assignment,
_unknown_tagged_fields,
})
}
pub fn write(&self, buf: &mut BytesMut, version: i16) -> Result<()> {
if version < 1 || version > 1 {
return Err(UnsupportedVersion::new(76, version).into());
}
write_i32(buf, self.throttle_time_ms);
write_i16(buf, self.error_code);
write_compact_nullable_string(buf, self.error_message.as_ref())?;
write_compact_nullable_string(buf, self.member_id.as_ref())?;
write_i32(buf, self.member_epoch);
write_i32(buf, self.heartbeat_interval_ms);
match &self.assignment {
None => {
write_i8(buf, -1);
},
Some(v) => {
write_i8(buf, 1);
v.write(buf, version)?;
},
}
let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
all_tags.sort_by_key(|f| f.tag);
write_tagged_fields(buf, &all_tags)?;
Ok(())
}
pub fn encoded_len(&self, version: i16) -> Result<usize> {
if version < 1 || version > 1 {
return Err(UnsupportedVersion::new(76, version).into());
}
let mut len: usize = 0;
len += 4;
len += 2;
len += compact_nullable_string_len(self.error_message.as_ref())?;
len += compact_nullable_string_len(self.member_id.as_ref())?;
len += 4;
len += 4;
match &self.assignment {
None => {
len += 1;
},
Some(v) => {
len += 1;
len += v.encoded_len(version)?;
},
}
let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
all_tags.sort_by_key(|f| f.tag);
len += tagged_fields_len(&all_tags)?;
Ok(len)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct Assignment {
pub topic_partitions: Vec<TopicPartitions>,
pub _unknown_tagged_fields: Vec<RawTaggedField>,
}
impl Default for Assignment {
fn default() -> Self {
Self {
topic_partitions: Vec::new(),
_unknown_tagged_fields: Vec::new(),
}
}
}
impl Assignment {
pub fn with_topic_partitions(mut self, value: Vec<TopicPartitions>) -> Self {
self.topic_partitions = value;
self
}
pub fn read(buf: &mut Bytes, version: i16) -> Result<Self> {
let topic_partitions;
let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
topic_partitions = {
let len = read_compact_array_length(buf)?;
let mut arr = Vec::with_capacity(len.max(0) as usize);
for _ in 0..len {
arr.push(TopicPartitions::read(buf, version)?);
}
arr
};
let tagged_fields = read_tagged_fields(buf)?;
for field in &tagged_fields {
match field.tag {
_ => {
_unknown_tagged_fields.push(field.clone());
},
}
}
Ok(Self {
topic_partitions,
_unknown_tagged_fields,
})
}
pub fn write(&self, buf: &mut BytesMut, version: i16) -> Result<()> {
write_compact_array_length(buf, self.topic_partitions.len() as i32);
for el in &self.topic_partitions {
el.write(buf, version)?;
}
let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
all_tags.sort_by_key(|f| f.tag);
write_tagged_fields(buf, &all_tags)?;
Ok(())
}
pub fn encoded_len(&self, version: i16) -> Result<usize> {
let mut len: usize = 0;
len += compact_array_length_len(self.topic_partitions.len() as i32);
for el in &self.topic_partitions {
len += el.encoded_len(version)?;
}
let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
all_tags.sort_by_key(|f| f.tag);
len += tagged_fields_len(&all_tags)?;
Ok(len)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct TopicPartitions {
pub topic_id: KafkaUuid,
pub partitions: Vec<i32>,
pub _unknown_tagged_fields: Vec<RawTaggedField>,
}
impl Default for TopicPartitions {
fn default() -> Self {
Self {
topic_id: KafkaUuid::ZERO,
partitions: Vec::new(),
_unknown_tagged_fields: Vec::new(),
}
}
}
impl TopicPartitions {
pub fn with_topic_id(mut self, value: KafkaUuid) -> Self {
self.topic_id = value;
self
}
pub fn with_partitions(mut self, value: Vec<i32>) -> Self {
self.partitions = value;
self
}
pub fn read(buf: &mut Bytes, _version: i16) -> Result<Self> {
let topic_id;
let partitions;
let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
topic_id = read_uuid(buf)?;
partitions = {
let len = read_compact_array_length(buf)?;
let mut arr = Vec::with_capacity(len.max(0) as usize);
for _ in 0..len {
arr.push(read_i32(buf)?);
}
arr
};
let tagged_fields = read_tagged_fields(buf)?;
for field in &tagged_fields {
match field.tag {
_ => {
_unknown_tagged_fields.push(field.clone());
},
}
}
Ok(Self {
topic_id,
partitions,
_unknown_tagged_fields,
})
}
pub fn write(&self, buf: &mut BytesMut, _version: i16) -> Result<()> {
write_uuid(buf, &self.topic_id);
write_compact_array_length(buf, self.partitions.len() as i32);
for el in &self.partitions {
write_i32(buf, *el);
}
let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
all_tags.sort_by_key(|f| f.tag);
write_tagged_fields(buf, &all_tags)?;
Ok(())
}
pub fn encoded_len(&self, _version: i16) -> Result<usize> {
let mut len: usize = 0;
len += 16;
len += compact_array_length_len(self.partitions.len() as i32);
len += self.partitions.len() * 4usize;
let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
all_tags.sort_by_key(|f| f.tag);
len += tagged_fields_len(&all_tags)?;
Ok(len)
}
}