use byteorder::ReadBytesExt;
use crate::codec::*;
use crate::IoResult;
#[derive(Debug, Default, Clone)]
pub struct FindCoordinatorRequest {
pub key: String,
pub key_type: i8,
pub coordinator_keys: Vec<String>,
pub unknown_tagged_fields: Vec<RawTaggedField>,
}
impl Decodable for FindCoordinatorRequest {
fn read<B: ReadBytesExt>(buf: &mut B, version: i16) -> IoResult<Self> {
let mut this = FindCoordinatorRequest::default();
if version <= 3 {
this.key = NullableString(version >= 3)
.decode(buf)?
.unwrap_or_default();
}
if version >= 1 {
this.key_type = Int8.decode(buf)?;
}
if version >= 4 {
this.coordinator_keys = NullableArray(NullableString(true), true)
.decode(buf)?
.unwrap_or_default()
.into_iter()
.map(|key| key.ok_or_else(|| err_decode_message_null("coordinatorKeys element")))
.collect::<std::io::Result<Vec<String>>>()?;
}
if version >= 3 {
this.unknown_tagged_fields = RawTaggedFieldList.decode(buf)?;
}
Ok(this)
}
}