#![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 InitializeShareGroupStateRequestData {
pub group_id: KafkaString,
pub topics: Vec<InitializeStateData>,
pub _unknown_tagged_fields: Vec<RawTaggedField>,
}
impl Default for InitializeShareGroupStateRequestData {
fn default() -> Self {
Self {
group_id: KafkaString::default(),
topics: Vec::new(),
_unknown_tagged_fields: Vec::new(),
}
}
}
impl InitializeShareGroupStateRequestData {
pub fn with_group_id(mut self, value: KafkaString) -> Self {
self.group_id = value;
self
}
pub fn with_topics(mut self, value: Vec<InitializeStateData>) -> Self {
self.topics = value;
self
}
pub fn read(buf: &mut Bytes, version: i16) -> Result<Self> {
if version < 0 || version > 0 {
return Err(UnsupportedVersion::new(83, version).into());
}
let group_id;
let topics;
let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
group_id = read_compact_string(buf)?;
topics = {
let len = read_compact_array_length(buf)?;
let mut arr = Vec::with_capacity(array_read_capacity(len, (buf).len()));
for _ in 0..len {
arr.push(InitializeStateData::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 {
group_id,
topics,
_unknown_tagged_fields,
})
}
pub fn write(&self, buf: &mut BytesMut, version: i16) -> Result<()> {
if version < 0 || version > 0 {
return Err(UnsupportedVersion::new(83, version).into());
}
write_compact_string(buf, &self.group_id)?;
write_compact_array_length(buf, self.topics.len() as i32);
for el in &self.topics {
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> {
if version < 0 || version > 0 {
return Err(UnsupportedVersion::new(83, version).into());
}
let mut len: usize = 0;
len += compact_string_len(&self.group_id)?;
len += compact_array_length_len(self.topics.len() as i32);
for el in &self.topics {
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 InitializeStateData {
pub topic_id: KafkaUuid,
pub partitions: Vec<PartitionData>,
pub _unknown_tagged_fields: Vec<RawTaggedField>,
}
impl Default for InitializeStateData {
fn default() -> Self {
Self {
topic_id: KafkaUuid::ZERO,
partitions: Vec::new(),
_unknown_tagged_fields: Vec::new(),
}
}
}
impl InitializeStateData {
pub fn with_topic_id(mut self, value: KafkaUuid) -> Self {
self.topic_id = value;
self
}
pub fn with_partitions(mut self, value: Vec<PartitionData>) -> 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(array_read_capacity(len, (buf).len()));
for _ in 0..len {
arr.push(PartitionData::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_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 {
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 += 16;
len += compact_array_length_len(self.partitions.len() as i32);
for el in &self.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 PartitionData {
pub partition: i32,
pub state_epoch: i32,
pub start_offset: i64,
pub _unknown_tagged_fields: Vec<RawTaggedField>,
}
impl Default for PartitionData {
fn default() -> Self {
Self {
partition: 0_i32,
state_epoch: 0_i32,
start_offset: 0_i64,
_unknown_tagged_fields: Vec::new(),
}
}
}
impl PartitionData {
pub fn with_partition(mut self, value: i32) -> Self {
self.partition = value;
self
}
pub fn with_state_epoch(mut self, value: i32) -> Self {
self.state_epoch = value;
self
}
pub fn with_start_offset(mut self, value: i64) -> Self {
self.start_offset = value;
self
}
pub fn read(buf: &mut Bytes, _version: i16) -> Result<Self> {
let partition;
let state_epoch;
let start_offset;
let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
partition = read_i32(buf)?;
state_epoch = read_i32(buf)?;
start_offset = read_i64(buf)?;
let tagged_fields = read_tagged_fields(buf)?;
for field in &tagged_fields {
match field.tag {
_ => {
_unknown_tagged_fields.push(field.clone());
},
}
}
Ok(Self {
partition,
state_epoch,
start_offset,
_unknown_tagged_fields,
})
}
pub fn write(&self, buf: &mut BytesMut, _version: i16) -> Result<()> {
write_i32(buf, self.partition);
write_i32(buf, self.state_epoch);
write_i64(buf, self.start_offset);
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 += 4;
len += 4;
len += 8;
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)
}
}