use byteorder::WriteBytesExt;
use crate::codec::Encodable;
use crate::codec::Encoder;
use crate::codec::FixedSizeEncoder;
use crate::codec::Int16;
use crate::codec::Int32;
use crate::codec::RawTaggedField;
use crate::codec::RawTaggedFieldList;
use crate::IoResult;
#[derive(Debug, Default, Clone)]
pub struct HeartbeatResponse {
pub throttle_time_ms: i32,
pub error_code: i16,
pub unknown_tagged_fields: Vec<RawTaggedField>,
}
impl Encodable for HeartbeatResponse {
fn write<B: WriteBytesExt>(&self, buf: &mut B, version: i16) -> IoResult<()> {
if version >= 1 {
Int32.encode(buf, self.throttle_time_ms)?;
}
Int16.encode(buf, self.error_code)?;
if version >= 4 {
RawTaggedFieldList.encode(buf, &self.unknown_tagged_fields)?;
}
Ok(())
}
fn calculate_size(&self, version: i16) -> usize {
let mut res = 0;
if version >= 1 {
res += Int32::SIZE; }
res += Int16::SIZE; if version >= 4 {
res += RawTaggedFieldList.calculate_size(&self.unknown_tagged_fields);
}
res
}
}