#![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 RenewDelegationTokenResponseData {
pub error_code: i16,
pub expiry_timestamp_ms: i64,
pub throttle_time_ms: i32,
pub _unknown_tagged_fields: Vec<RawTaggedField>,
}
impl Default for RenewDelegationTokenResponseData {
fn default() -> Self {
Self {
error_code: 0_i16,
expiry_timestamp_ms: 0_i64,
throttle_time_ms: 0_i32,
_unknown_tagged_fields: Vec::new(),
}
}
}
impl RenewDelegationTokenResponseData {
pub fn with_error_code(mut self, value: i16) -> Self {
self.error_code = value;
self
}
pub fn with_expiry_timestamp_ms(mut self, value: i64) -> Self {
self.expiry_timestamp_ms = value;
self
}
pub fn with_throttle_time_ms(mut self, value: i32) -> Self {
self.throttle_time_ms = value;
self
}
pub fn read(buf: &mut Bytes, version: i16) -> Result<Self> {
if version < 1 || version > 2 {
return Err(UnsupportedVersion::new(39, version).into());
}
let error_code;
let expiry_timestamp_ms;
let throttle_time_ms;
let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
error_code = read_i16(buf)?;
expiry_timestamp_ms = read_i64(buf)?;
throttle_time_ms = read_i32(buf)?;
if version >= 2 {
let tagged_fields = read_tagged_fields(buf)?;
for field in &tagged_fields {
match field.tag {
_ => {
_unknown_tagged_fields.push(field.clone());
},
}
}
}
Ok(Self {
error_code,
expiry_timestamp_ms,
throttle_time_ms,
_unknown_tagged_fields,
})
}
pub fn write(&self, buf: &mut BytesMut, version: i16) -> Result<()> {
if version < 1 || version > 2 {
return Err(UnsupportedVersion::new(39, version).into());
}
write_i16(buf, self.error_code);
write_i64(buf, self.expiry_timestamp_ms);
write_i32(buf, self.throttle_time_ms);
if version >= 2 {
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 > 2 {
return Err(UnsupportedVersion::new(39, version).into());
}
let mut len: usize = 0;
len += 2;
len += 8;
len += 4;
if version >= 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)
}
}