#![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 StreamsGroupHeartbeatRequestData {
pub group_id: KafkaString,
pub member_id: KafkaString,
pub member_epoch: i32,
pub endpoint_information_epoch: i32,
pub instance_id: Option<KafkaString>,
pub rack_id: Option<KafkaString>,
pub rebalance_timeout_ms: i32,
pub topology: Option<Box<Topology>>,
pub active_tasks: Option<Vec<TaskIds>>,
pub standby_tasks: Option<Vec<TaskIds>>,
pub warmup_tasks: Option<Vec<TaskIds>>,
pub process_id: Option<KafkaString>,
pub user_endpoint: Option<Box<Endpoint>>,
pub client_tags: Option<Vec<KeyValue>>,
pub task_offsets: Option<Vec<TaskOffset>>,
pub task_end_offsets: Option<Vec<TaskOffset>>,
pub shutdown_application: bool,
pub _unknown_tagged_fields: Vec<RawTaggedField>,
}
impl Default for StreamsGroupHeartbeatRequestData {
fn default() -> Self {
Self {
group_id: KafkaString::default(),
member_id: KafkaString::default(),
member_epoch: 0_i32,
endpoint_information_epoch: 0_i32,
instance_id: None,
rack_id: None,
rebalance_timeout_ms: -1i32,
topology: None,
active_tasks: None,
standby_tasks: None,
warmup_tasks: None,
process_id: None,
user_endpoint: None,
client_tags: None,
task_offsets: None,
task_end_offsets: None,
shutdown_application: false,
_unknown_tagged_fields: Vec::new(),
}
}
}
impl StreamsGroupHeartbeatRequestData {
pub fn with_group_id(mut self, value: KafkaString) -> Self {
self.group_id = 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_endpoint_information_epoch(mut self, value: i32) -> Self {
self.endpoint_information_epoch = value;
self
}
pub fn with_instance_id(mut self, value: Option<KafkaString>) -> Self {
self.instance_id = value;
self
}
pub fn with_rack_id(mut self, value: Option<KafkaString>) -> Self {
self.rack_id = value;
self
}
pub fn with_rebalance_timeout_ms(mut self, value: i32) -> Self {
self.rebalance_timeout_ms = value;
self
}
pub fn with_topology(mut self, value: Option<Box<Topology>>) -> Self {
self.topology = 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_process_id(mut self, value: Option<KafkaString>) -> Self {
self.process_id = value;
self
}
pub fn with_user_endpoint(mut self, value: Option<Box<Endpoint>>) -> Self {
self.user_endpoint = value;
self
}
pub fn with_client_tags(mut self, value: Option<Vec<KeyValue>>) -> Self {
self.client_tags = value;
self
}
pub fn with_task_offsets(mut self, value: Option<Vec<TaskOffset>>) -> Self {
self.task_offsets = value;
self
}
pub fn with_task_end_offsets(mut self, value: Option<Vec<TaskOffset>>) -> Self {
self.task_end_offsets = value;
self
}
pub fn with_shutdown_application(mut self, value: bool) -> Self {
self.shutdown_application = 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 group_id;
let member_id;
let member_epoch;
let endpoint_information_epoch;
let instance_id;
let rack_id;
let rebalance_timeout_ms;
let topology;
let active_tasks;
let standby_tasks;
let warmup_tasks;
let process_id;
let user_endpoint;
let client_tags;
let task_offsets;
let task_end_offsets;
let shutdown_application;
let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
group_id = read_compact_string(buf)?;
member_id = read_compact_string(buf)?;
member_epoch = read_i32(buf)?;
endpoint_information_epoch = read_i32(buf)?;
instance_id = read_compact_nullable_string(buf)?;
rack_id = read_compact_nullable_string(buf)?;
rebalance_timeout_ms = read_i32(buf)?;
topology = {
let marker = read_i8(buf)?;
if marker < 0 {
None
} else {
Some(Box::new(Topology::read(buf, version)?))
}
};
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)
}
};
process_id = read_compact_nullable_string(buf)?;
user_endpoint = {
let marker = read_i8(buf)?;
if marker < 0 {
None
} else {
Some(Box::new(Endpoint::read(buf, version)?))
}
};
client_tags = {
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(KeyValue::read(buf, version)?);
}
Some(arr)
}
};
task_offsets = {
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(TaskOffset::read(buf, version)?);
}
Some(arr)
}
};
task_end_offsets = {
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(TaskOffset::read(buf, version)?);
}
Some(arr)
}
};
shutdown_application = read_bool(buf)?;
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,
member_id,
member_epoch,
endpoint_information_epoch,
instance_id,
rack_id,
rebalance_timeout_ms,
topology,
active_tasks,
standby_tasks,
warmup_tasks,
process_id,
user_endpoint,
client_tags,
task_offsets,
task_end_offsets,
shutdown_application,
_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_compact_string(buf, &self.group_id)?;
write_compact_string(buf, &self.member_id)?;
write_i32(buf, self.member_epoch);
write_i32(buf, self.endpoint_information_epoch);
write_compact_nullable_string(buf, self.instance_id.as_ref())?;
write_compact_nullable_string(buf, self.rack_id.as_ref())?;
write_i32(buf, self.rebalance_timeout_ms);
match &self.topology {
None => {
write_i8(buf, -1);
},
Some(v) => {
write_i8(buf, 1);
v.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_compact_nullable_string(buf, self.process_id.as_ref())?;
match &self.user_endpoint {
None => {
write_i8(buf, -1);
},
Some(v) => {
write_i8(buf, 1);
v.write(buf, version)?;
},
}
match &self.client_tags {
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.task_offsets {
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.task_end_offsets {
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_bool(buf, self.shutdown_application);
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 += compact_string_len(&self.group_id)?;
len += compact_string_len(&self.member_id)?;
len += 4;
len += 4;
len += compact_nullable_string_len(self.instance_id.as_ref())?;
len += compact_nullable_string_len(self.rack_id.as_ref())?;
len += 4;
match &self.topology {
None => {
len += 1;
},
Some(v) => {
len += 1;
len += v.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 += compact_nullable_string_len(self.process_id.as_ref())?;
match &self.user_endpoint {
None => {
len += 1;
},
Some(v) => {
len += 1;
len += v.encoded_len(version)?;
},
}
match &self.client_tags {
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.task_offsets {
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.task_end_offsets {
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 += 1;
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 Topology {
pub epoch: i32,
pub subtopologies: Vec<Subtopology>,
pub _unknown_tagged_fields: Vec<RawTaggedField>,
}
impl Default for Topology {
fn default() -> Self {
Self {
epoch: 0_i32,
subtopologies: Vec::new(),
_unknown_tagged_fields: Vec::new(),
}
}
}
impl Topology {
pub fn with_epoch(mut self, value: i32) -> Self {
self.epoch = value;
self
}
pub fn with_subtopologies(mut self, value: Vec<Subtopology>) -> Self {
self.subtopologies = value;
self
}
pub fn read(buf: &mut Bytes, version: i16) -> Result<Self> {
let epoch;
let subtopologies;
let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
epoch = read_i32(buf)?;
subtopologies = {
let len = read_compact_array_length(buf)?;
let mut arr = Vec::with_capacity(len.max(0) as usize);
for _ in 0..len {
arr.push(Subtopology::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 {
epoch,
subtopologies,
_unknown_tagged_fields,
})
}
pub fn write(&self, buf: &mut BytesMut, version: i16) -> Result<()> {
write_i32(buf, self.epoch);
write_compact_array_length(buf, self.subtopologies.len() as i32);
for el in &self.subtopologies {
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 += 4;
len += compact_array_length_len(self.subtopologies.len() as i32);
for el in &self.subtopologies {
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 Subtopology {
pub subtopology_id: KafkaString,
pub source_topics: Vec<KafkaString>,
pub source_topic_regex: Vec<KafkaString>,
pub state_changelog_topics: Vec<TopicInfo>,
pub repartition_sink_topics: Vec<KafkaString>,
pub repartition_source_topics: Vec<TopicInfo>,
pub copartition_groups: Vec<CopartitionGroup>,
pub _unknown_tagged_fields: Vec<RawTaggedField>,
}
impl Default for Subtopology {
fn default() -> Self {
Self {
subtopology_id: KafkaString::default(),
source_topics: Vec::new(),
source_topic_regex: Vec::new(),
state_changelog_topics: Vec::new(),
repartition_sink_topics: Vec::new(),
repartition_source_topics: Vec::new(),
copartition_groups: Vec::new(),
_unknown_tagged_fields: Vec::new(),
}
}
}
impl Subtopology {
pub fn with_subtopology_id(mut self, value: KafkaString) -> Self {
self.subtopology_id = value;
self
}
pub fn with_source_topics(mut self, value: Vec<KafkaString>) -> Self {
self.source_topics = value;
self
}
pub fn with_source_topic_regex(mut self, value: Vec<KafkaString>) -> Self {
self.source_topic_regex = value;
self
}
pub fn with_state_changelog_topics(mut self, value: Vec<TopicInfo>) -> Self {
self.state_changelog_topics = value;
self
}
pub fn with_repartition_sink_topics(mut self, value: Vec<KafkaString>) -> Self {
self.repartition_sink_topics = value;
self
}
pub fn with_repartition_source_topics(mut self, value: Vec<TopicInfo>) -> Self {
self.repartition_source_topics = value;
self
}
pub fn with_copartition_groups(mut self, value: Vec<CopartitionGroup>) -> Self {
self.copartition_groups = value;
self
}
pub fn read(buf: &mut Bytes, version: i16) -> Result<Self> {
let subtopology_id;
let source_topics;
let source_topic_regex;
let state_changelog_topics;
let repartition_sink_topics;
let repartition_source_topics;
let copartition_groups;
let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
subtopology_id = read_compact_string(buf)?;
source_topics = {
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_compact_string(buf)?);
}
arr
};
source_topic_regex = {
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_compact_string(buf)?);
}
arr
};
state_changelog_topics = {
let len = read_compact_array_length(buf)?;
let mut arr = Vec::with_capacity(len.max(0) as usize);
for _ in 0..len {
arr.push(TopicInfo::read(buf, version)?);
}
arr
};
repartition_sink_topics = {
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_compact_string(buf)?);
}
arr
};
repartition_source_topics = {
let len = read_compact_array_length(buf)?;
let mut arr = Vec::with_capacity(len.max(0) as usize);
for _ in 0..len {
arr.push(TopicInfo::read(buf, version)?);
}
arr
};
copartition_groups = {
let len = read_compact_array_length(buf)?;
let mut arr = Vec::with_capacity(len.max(0) as usize);
for _ in 0..len {
arr.push(CopartitionGroup::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 {
subtopology_id,
source_topics,
source_topic_regex,
state_changelog_topics,
repartition_sink_topics,
repartition_source_topics,
copartition_groups,
_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.source_topics.len() as i32);
for el in &self.source_topics {
write_compact_string(buf, el)?;
}
write_compact_array_length(buf, self.source_topic_regex.len() as i32);
for el in &self.source_topic_regex {
write_compact_string(buf, el)?;
}
write_compact_array_length(buf, self.state_changelog_topics.len() as i32);
for el in &self.state_changelog_topics {
el.write(buf, version)?;
}
write_compact_array_length(buf, self.repartition_sink_topics.len() as i32);
for el in &self.repartition_sink_topics {
write_compact_string(buf, el)?;
}
write_compact_array_length(buf, self.repartition_source_topics.len() as i32);
for el in &self.repartition_source_topics {
el.write(buf, version)?;
}
write_compact_array_length(buf, self.copartition_groups.len() as i32);
for el in &self.copartition_groups {
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_string_len(&self.subtopology_id)?;
len += compact_array_length_len(self.source_topics.len() as i32);
for el in &self.source_topics {
len += compact_string_len(el)?;
}
len += compact_array_length_len(self.source_topic_regex.len() as i32);
for el in &self.source_topic_regex {
len += compact_string_len(el)?;
}
len += compact_array_length_len(self.state_changelog_topics.len() as i32);
for el in &self.state_changelog_topics {
len += el.encoded_len(version)?;
}
len += compact_array_length_len(self.repartition_sink_topics.len() as i32);
for el in &self.repartition_sink_topics {
len += compact_string_len(el)?;
}
len += compact_array_length_len(self.repartition_source_topics.len() as i32);
for el in &self.repartition_source_topics {
len += el.encoded_len(version)?;
}
len += compact_array_length_len(self.copartition_groups.len() as i32);
for el in &self.copartition_groups {
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 CopartitionGroup {
pub source_topics: Vec<i16>,
pub source_topic_regex: Vec<i16>,
pub repartition_source_topics: Vec<i16>,
pub _unknown_tagged_fields: Vec<RawTaggedField>,
}
impl Default for CopartitionGroup {
fn default() -> Self {
Self {
source_topics: Vec::new(),
source_topic_regex: Vec::new(),
repartition_source_topics: Vec::new(),
_unknown_tagged_fields: Vec::new(),
}
}
}
impl CopartitionGroup {
pub fn with_source_topics(mut self, value: Vec<i16>) -> Self {
self.source_topics = value;
self
}
pub fn with_source_topic_regex(mut self, value: Vec<i16>) -> Self {
self.source_topic_regex = value;
self
}
pub fn with_repartition_source_topics(mut self, value: Vec<i16>) -> Self {
self.repartition_source_topics = value;
self
}
pub fn read(buf: &mut Bytes, _version: i16) -> Result<Self> {
let source_topics;
let source_topic_regex;
let repartition_source_topics;
let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
source_topics = {
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_i16(buf)?);
}
arr
};
source_topic_regex = {
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_i16(buf)?);
}
arr
};
repartition_source_topics = {
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_i16(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 {
source_topics,
source_topic_regex,
repartition_source_topics,
_unknown_tagged_fields,
})
}
pub fn write(&self, buf: &mut BytesMut, _version: i16) -> Result<()> {
write_compact_array_length(buf, self.source_topics.len() as i32);
for el in &self.source_topics {
write_i16(buf, *el);
}
write_compact_array_length(buf, self.source_topic_regex.len() as i32);
for el in &self.source_topic_regex {
write_i16(buf, *el);
}
write_compact_array_length(buf, self.repartition_source_topics.len() as i32);
for el in &self.repartition_source_topics {
write_i16(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_array_length_len(self.source_topics.len() as i32);
len += self.source_topics.len() * 2usize;
len += compact_array_length_len(self.source_topic_regex.len() as i32);
len += self.source_topic_regex.len() * 2usize;
len += compact_array_length_len(self.repartition_source_topics.len() as i32);
len += self.repartition_source_topics.len() * 2usize;
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 KeyValue {
pub key: KafkaString,
pub value: KafkaString,
pub _unknown_tagged_fields: Vec<RawTaggedField>,
}
impl Default for KeyValue {
fn default() -> Self {
Self {
key: KafkaString::default(),
value: KafkaString::default(),
_unknown_tagged_fields: Vec::new(),
}
}
}
impl KeyValue {
pub fn with_key(mut self, value: KafkaString) -> Self {
self.key = value;
self
}
pub fn with_value(mut self, value: KafkaString) -> Self {
self.value = value;
self
}
pub fn read(buf: &mut Bytes, _version: i16) -> Result<Self> {
let key;
let value;
let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
key = read_compact_string(buf)?;
value = 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 {
key,
value,
_unknown_tagged_fields,
})
}
pub fn write(&self, buf: &mut BytesMut, _version: i16) -> Result<()> {
write_compact_string(buf, &self.key)?;
write_compact_string(buf, &self.value)?;
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.key)?;
len += compact_string_len(&self.value)?;
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 TopicInfo {
pub name: KafkaString,
pub partitions: i32,
pub replication_factor: i16,
pub topic_configs: Vec<KeyValue>,
pub _unknown_tagged_fields: Vec<RawTaggedField>,
}
impl Default for TopicInfo {
fn default() -> Self {
Self {
name: KafkaString::default(),
partitions: 0_i32,
replication_factor: 0_i16,
topic_configs: Vec::new(),
_unknown_tagged_fields: Vec::new(),
}
}
}
impl TopicInfo {
pub fn with_name(mut self, value: KafkaString) -> Self {
self.name = value;
self
}
pub fn with_partitions(mut self, value: i32) -> Self {
self.partitions = value;
self
}
pub fn with_replication_factor(mut self, value: i16) -> Self {
self.replication_factor = value;
self
}
pub fn with_topic_configs(mut self, value: Vec<KeyValue>) -> Self {
self.topic_configs = value;
self
}
pub fn read(buf: &mut Bytes, version: i16) -> Result<Self> {
let name;
let partitions;
let replication_factor;
let topic_configs;
let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
name = read_compact_string(buf)?;
partitions = read_i32(buf)?;
replication_factor = read_i16(buf)?;
topic_configs = {
let len = read_compact_array_length(buf)?;
let mut arr = Vec::with_capacity(len.max(0) as usize);
for _ in 0..len {
arr.push(KeyValue::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 {
name,
partitions,
replication_factor,
topic_configs,
_unknown_tagged_fields,
})
}
pub fn write(&self, buf: &mut BytesMut, version: i16) -> Result<()> {
write_compact_string(buf, &self.name)?;
write_i32(buf, self.partitions);
write_i16(buf, self.replication_factor);
write_compact_array_length(buf, self.topic_configs.len() as i32);
for el in &self.topic_configs {
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_string_len(&self.name)?;
len += 4;
len += 2;
len += compact_array_length_len(self.topic_configs.len() as i32);
for el in &self.topic_configs {
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 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)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct TaskOffset {
pub subtopology_id: KafkaString,
pub partition: i32,
pub offset: i64,
pub _unknown_tagged_fields: Vec<RawTaggedField>,
}
impl Default for TaskOffset {
fn default() -> Self {
Self {
subtopology_id: KafkaString::default(),
partition: 0_i32,
offset: 0_i64,
_unknown_tagged_fields: Vec::new(),
}
}
}
impl TaskOffset {
pub fn with_subtopology_id(mut self, value: KafkaString) -> Self {
self.subtopology_id = value;
self
}
pub fn with_partition(mut self, value: i32) -> Self {
self.partition = value;
self
}
pub fn with_offset(mut self, value: i64) -> Self {
self.offset = value;
self
}
pub fn read(buf: &mut Bytes, _version: i16) -> Result<Self> {
let subtopology_id;
let partition;
let offset;
let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
subtopology_id = read_compact_string(buf)?;
partition = read_i32(buf)?;
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 {
subtopology_id,
partition,
offset,
_unknown_tagged_fields,
})
}
pub fn write(&self, buf: &mut BytesMut, _version: i16) -> Result<()> {
write_compact_string(buf, &self.subtopology_id)?;
write_i32(buf, self.partition);
write_i64(buf, self.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 += compact_string_len(&self.subtopology_id)?;
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)
}
}
#[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)
}
}