#![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 StreamsGroupHeartbeatResponseData {
pub throttle_time_ms: i32,
pub error_code: i16,
pub error_message: Option<KafkaString>,
pub member_id: KafkaString,
pub member_epoch: i32,
pub heartbeat_interval_ms: i32,
pub acceptable_recovery_lag: i32,
pub task_offset_interval_ms: i32,
pub status: Option<Vec<Status>>,
pub active_tasks: Option<Vec<TaskIds>>,
pub standby_tasks: Option<Vec<TaskIds>>,
pub warmup_tasks: Option<Vec<TaskIds>>,
pub endpoint_information_epoch: i32,
pub partitions_by_user_endpoint: Option<Vec<EndpointToPartitions>>,
pub _unknown_tagged_fields: Vec<RawTaggedField>,
}
impl Default for StreamsGroupHeartbeatResponseData {
fn default() -> Self {
Self {
throttle_time_ms: 0_i32,
error_code: 0_i16,
error_message: None,
member_id: KafkaString::default(),
member_epoch: 0_i32,
heartbeat_interval_ms: 0_i32,
acceptable_recovery_lag: 0_i32,
task_offset_interval_ms: 0_i32,
status: None,
active_tasks: None,
standby_tasks: None,
warmup_tasks: None,
endpoint_information_epoch: 0_i32,
partitions_by_user_endpoint: None,
_unknown_tagged_fields: Vec::new(),
}
}
}
impl StreamsGroupHeartbeatResponseData {
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: 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_acceptable_recovery_lag(mut self, value: i32) -> Self {
self.acceptable_recovery_lag = value;
self
}
pub fn with_task_offset_interval_ms(mut self, value: i32) -> Self {
self.task_offset_interval_ms = value;
self
}
pub fn with_status(mut self, value: Option<Vec<Status>>) -> Self {
self.status = value;
self
}
pub fn with_active_tasks(mut self, value: Option<Vec<TaskIds>>) -> Self {
self.active_tasks = value;
self
}
pub fn with_standby_tasks(mut self, value: Option<Vec<TaskIds>>) -> Self {
self.standby_tasks = value;
self
}
pub fn with_warmup_tasks(mut self, value: Option<Vec<TaskIds>>) -> Self {
self.warmup_tasks = value;
self
}
pub fn with_endpoint_information_epoch(mut self, value: i32) -> Self {
self.endpoint_information_epoch = value;
self
}
pub fn with_partitions_by_user_endpoint(
mut self,
value: Option<Vec<EndpointToPartitions>>,
) -> Self {
self.partitions_by_user_endpoint = value;
self
}
pub fn read(buf: &mut Bytes, version: i16) -> Result<Self> {
if version < 0 || version > 0 {
return Err(UnsupportedVersion::new(88, version).into());
}
let throttle_time_ms;
let error_code;
let error_message;
let member_id;
let member_epoch;
let heartbeat_interval_ms;
let acceptable_recovery_lag;
let task_offset_interval_ms;
let status;
let active_tasks;
let standby_tasks;
let warmup_tasks;
let endpoint_information_epoch;
let partitions_by_user_endpoint;
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_string(buf)?;
member_epoch = read_i32(buf)?;
heartbeat_interval_ms = read_i32(buf)?;
acceptable_recovery_lag = read_i32(buf)?;
task_offset_interval_ms = read_i32(buf)?;
status = {
let len = read_compact_array_length(buf)?;
if len < 0 {
None
} else {
let mut arr = Vec::with_capacity(len as usize);
for _ in 0..len {
arr.push(Status::read(buf, version)?);
}
Some(arr)
}
};
active_tasks = {
let len = read_compact_array_length(buf)?;
if len < 0 {
None
} else {
let mut arr = Vec::with_capacity(len as usize);
for _ in 0..len {
arr.push(TaskIds::read(buf, version)?);
}
Some(arr)
}
};
standby_tasks = {
let len = read_compact_array_length(buf)?;
if len < 0 {
None
} else {
let mut arr = Vec::with_capacity(len as usize);
for _ in 0..len {
arr.push(TaskIds::read(buf, version)?);
}
Some(arr)
}
};
warmup_tasks = {
let len = read_compact_array_length(buf)?;
if len < 0 {
None
} else {
let mut arr = Vec::with_capacity(len as usize);
for _ in 0..len {
arr.push(TaskIds::read(buf, version)?);
}
Some(arr)
}
};
endpoint_information_epoch = read_i32(buf)?;
partitions_by_user_endpoint = {
let len = read_compact_array_length(buf)?;
if len < 0 {
None
} else {
let mut arr = Vec::with_capacity(len as usize);
for _ in 0..len {
arr.push(EndpointToPartitions::read(buf, version)?);
}
Some(arr)
}
};
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,
acceptable_recovery_lag,
task_offset_interval_ms,
status,
active_tasks,
standby_tasks,
warmup_tasks,
endpoint_information_epoch,
partitions_by_user_endpoint,
_unknown_tagged_fields,
})
}
pub fn write(&self, buf: &mut BytesMut, version: i16) -> Result<()> {
if version < 0 || version > 0 {
return Err(UnsupportedVersion::new(88, 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_string(buf, &self.member_id)?;
write_i32(buf, self.member_epoch);
write_i32(buf, self.heartbeat_interval_ms);
write_i32(buf, self.acceptable_recovery_lag);
write_i32(buf, self.task_offset_interval_ms);
match &self.status {
None => {
write_compact_array_length(buf, -1);
},
Some(arr) => {
write_compact_array_length(buf, arr.len() as i32);
for el in arr {
el.write(buf, version)?;
}
},
}
match &self.active_tasks {
None => {
write_compact_array_length(buf, -1);
},
Some(arr) => {
write_compact_array_length(buf, arr.len() as i32);
for el in arr {
el.write(buf, version)?;
}
},
}
match &self.standby_tasks {
None => {
write_compact_array_length(buf, -1);
},
Some(arr) => {
write_compact_array_length(buf, arr.len() as i32);
for el in arr {
el.write(buf, version)?;
}
},
}
match &self.warmup_tasks {
None => {
write_compact_array_length(buf, -1);
},
Some(arr) => {
write_compact_array_length(buf, arr.len() as i32);
for el in arr {
el.write(buf, version)?;
}
},
}
write_i32(buf, self.endpoint_information_epoch);
match &self.partitions_by_user_endpoint {
None => {
write_compact_array_length(buf, -1);
},
Some(arr) => {
write_compact_array_length(buf, arr.len() as i32);
for el in arr {
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(88, version).into());
}
let mut len: usize = 0;
len += 4;
len += 2;
len += compact_nullable_string_len(self.error_message.as_ref())?;
len += compact_string_len(&self.member_id)?;
len += 4;
len += 4;
len += 4;
len += 4;
match &self.status {
None => {
len += compact_array_length_len(-1);
},
Some(arr) => {
len += compact_array_length_len(arr.len() as i32);
for el in arr {
len += el.encoded_len(version)?;
}
},
}
match &self.active_tasks {
None => {
len += compact_array_length_len(-1);
},
Some(arr) => {
len += compact_array_length_len(arr.len() as i32);
for el in arr {
len += el.encoded_len(version)?;
}
},
}
match &self.standby_tasks {
None => {
len += compact_array_length_len(-1);
},
Some(arr) => {
len += compact_array_length_len(arr.len() as i32);
for el in arr {
len += el.encoded_len(version)?;
}
},
}
match &self.warmup_tasks {
None => {
len += compact_array_length_len(-1);
},
Some(arr) => {
len += compact_array_length_len(arr.len() as i32);
for el in arr {
len += el.encoded_len(version)?;
}
},
}
len += 4;
match &self.partitions_by_user_endpoint {
None => {
len += compact_array_length_len(-1);
},
Some(arr) => {
len += compact_array_length_len(arr.len() as i32);
for el in arr {
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 EndpointToPartitions {
pub user_endpoint: Endpoint,
pub active_partitions: Vec<TopicPartition>,
pub standby_partitions: Vec<TopicPartition>,
pub _unknown_tagged_fields: Vec<RawTaggedField>,
}
impl Default for EndpointToPartitions {
fn default() -> Self {
Self {
user_endpoint: Endpoint::default(),
active_partitions: Vec::new(),
standby_partitions: Vec::new(),
_unknown_tagged_fields: Vec::new(),
}
}
}
impl EndpointToPartitions {
pub fn with_user_endpoint(mut self, value: Endpoint) -> Self {
self.user_endpoint = value;
self
}
pub fn with_active_partitions(mut self, value: Vec<TopicPartition>) -> Self {
self.active_partitions = value;
self
}
pub fn with_standby_partitions(mut self, value: Vec<TopicPartition>) -> Self {
self.standby_partitions = value;
self
}
pub fn read(buf: &mut Bytes, version: i16) -> Result<Self> {
let user_endpoint;
let active_partitions;
let standby_partitions;
let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
user_endpoint = Endpoint::read(buf, version)?;
active_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(TopicPartition::read(buf, version)?);
}
arr
};
standby_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(TopicPartition::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 {
user_endpoint,
active_partitions,
standby_partitions,
_unknown_tagged_fields,
})
}
pub fn write(&self, buf: &mut BytesMut, version: i16) -> Result<()> {
self.user_endpoint.write(buf, version)?;
write_compact_array_length(buf, self.active_partitions.len() as i32);
for el in &self.active_partitions {
el.write(buf, version)?;
}
write_compact_array_length(buf, self.standby_partitions.len() as i32);
for el in &self.standby_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 += self.user_endpoint.encoded_len(version)?;
len += compact_array_length_len(self.active_partitions.len() as i32);
for el in &self.active_partitions {
len += el.encoded_len(version)?;
}
len += compact_array_length_len(self.standby_partitions.len() as i32);
for el in &self.standby_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 Status {
pub status_code: i8,
pub status_detail: KafkaString,
pub _unknown_tagged_fields: Vec<RawTaggedField>,
}
impl Default for Status {
fn default() -> Self {
Self {
status_code: 0_i8,
status_detail: KafkaString::default(),
_unknown_tagged_fields: Vec::new(),
}
}
}
impl Status {
pub fn with_status_code(mut self, value: i8) -> Self {
self.status_code = value;
self
}
pub fn with_status_detail(mut self, value: KafkaString) -> Self {
self.status_detail = value;
self
}
pub fn read(buf: &mut Bytes, _version: i16) -> Result<Self> {
let status_code;
let status_detail;
let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
status_code = read_i8(buf)?;
status_detail = read_compact_string(buf)?;
let tagged_fields = read_tagged_fields(buf)?;
for field in &tagged_fields {
match field.tag {
_ => {
_unknown_tagged_fields.push(field.clone());
},
}
}
Ok(Self {
status_code,
status_detail,
_unknown_tagged_fields,
})
}
pub fn write(&self, buf: &mut BytesMut, _version: i16) -> Result<()> {
write_i8(buf, self.status_code);
write_compact_string(buf, &self.status_detail)?;
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 += 1;
len += compact_string_len(&self.status_detail)?;
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 TopicPartition {
pub topic: KafkaString,
pub partitions: Vec<i32>,
pub _unknown_tagged_fields: Vec<RawTaggedField>,
}
impl Default for TopicPartition {
fn default() -> Self {
Self {
topic: KafkaString::default(),
partitions: Vec::new(),
_unknown_tagged_fields: Vec::new(),
}
}
}
impl TopicPartition {
pub fn with_topic(mut self, value: KafkaString) -> Self {
self.topic = 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;
let partitions;
let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
topic = read_compact_string(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,
partitions,
_unknown_tagged_fields,
})
}
pub fn write(&self, buf: &mut BytesMut, _version: i16) -> Result<()> {
write_compact_string(buf, &self.topic)?;
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 += compact_string_len(&self.topic)?;
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)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct TaskIds {
pub subtopology_id: KafkaString,
pub partitions: Vec<i32>,
pub _unknown_tagged_fields: Vec<RawTaggedField>,
}
impl Default for TaskIds {
fn default() -> Self {
Self {
subtopology_id: KafkaString::default(),
partitions: Vec::new(),
_unknown_tagged_fields: Vec::new(),
}
}
}
impl TaskIds {
pub fn with_subtopology_id(mut self, value: KafkaString) -> Self {
self.subtopology_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 subtopology_id;
let partitions;
let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
subtopology_id = read_compact_string(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 {
subtopology_id,
partitions,
_unknown_tagged_fields,
})
}
pub fn write(&self, buf: &mut BytesMut, _version: i16) -> Result<()> {
write_compact_string(buf, &self.subtopology_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 += compact_string_len(&self.subtopology_id)?;
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)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct Endpoint {
pub host: KafkaString,
pub port: u16,
pub _unknown_tagged_fields: Vec<RawTaggedField>,
}
impl Default for Endpoint {
fn default() -> Self {
Self {
host: KafkaString::default(),
port: 0_u16,
_unknown_tagged_fields: Vec::new(),
}
}
}
impl Endpoint {
pub fn with_host(mut self, value: KafkaString) -> Self {
self.host = value;
self
}
pub fn with_port(mut self, value: u16) -> Self {
self.port = value;
self
}
pub fn read(buf: &mut Bytes, _version: i16) -> Result<Self> {
let host;
let port;
let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
host = read_compact_string(buf)?;
port = read_u16(buf)?;
let tagged_fields = read_tagged_fields(buf)?;
for field in &tagged_fields {
match field.tag {
_ => {
_unknown_tagged_fields.push(field.clone());
},
}
}
Ok(Self {
host,
port,
_unknown_tagged_fields,
})
}
pub fn write(&self, buf: &mut BytesMut, _version: i16) -> Result<()> {
write_compact_string(buf, &self.host)?;
write_u16(buf, self.port);
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_string_len(&self.host)?;
len += 2;
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)
}
}