#![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 AllocateProducerIdsRequestData {
pub broker_id: i32,
pub broker_epoch: i64,
pub _unknown_tagged_fields: Vec<RawTaggedField>,
}
impl Default for AllocateProducerIdsRequestData {
fn default() -> Self {
Self {
broker_id: 0_i32,
broker_epoch: -1i64,
_unknown_tagged_fields: Vec::new(),
}
}
}
impl AllocateProducerIdsRequestData {
pub fn with_broker_id(mut self, value: i32) -> Self {
self.broker_id = value;
self
}
pub fn with_broker_epoch(mut self, value: i64) -> Self {
self.broker_epoch = value;
self
}
pub fn read(buf: &mut Bytes, version: i16) -> Result<Self> {
if version < 0 || version > 0 {
return Err(UnsupportedVersion::new(67, version).into());
}
let broker_id;
let broker_epoch;
let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
broker_id = read_i32(buf)?;
broker_epoch = 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 {
broker_id,
broker_epoch,
_unknown_tagged_fields,
})
}
pub fn write(&self, buf: &mut BytesMut, version: i16) -> Result<()> {
if version < 0 || version > 0 {
return Err(UnsupportedVersion::new(67, version).into());
}
write_i32(buf, self.broker_id);
write_i64(buf, self.broker_epoch);
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(67, version).into());
}
let mut len: usize = 0;
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)
}
}