use bytes::{Buf, BufMut, BytesMut};
#[derive(Clone, Debug)]
pub struct RadioEntityType {
pub entity_kind: u8,
pub domain: u8,
pub country: u16,
pub category: u8,
pub nomenclature_version: u8,
pub nomenclature: u16,
}
impl Default for RadioEntityType {
fn default() -> Self {
RadioEntityType {
entity_kind: 0,
domain: 0,
country: 0,
category: 0,
nomenclature_version: 0,
nomenclature: 0,
}
}
}
impl RadioEntityType {
pub fn new(
entity_kind: u8,
domain: u8,
country: u16,
category: u8,
nomenclature_version: u8,
nomenclature: u16,
) -> Self {
RadioEntityType {
entity_kind,
domain,
country,
category,
nomenclature_version,
nomenclature,
}
}
pub fn serialize(&self, buf: &mut BytesMut) {
buf.put_u8(self.entity_kind);
buf.put_u8(self.domain);
buf.put_u16(self.country);
buf.put_u8(self.category);
buf.put_u8(self.nomenclature_version);
buf.put_u16(self.nomenclature);
}
pub fn decode(buf: &mut BytesMut) -> RadioEntityType {
RadioEntityType {
entity_kind: buf.get_u8(),
domain: buf.get_u8(),
country: buf.get_u16(),
category: buf.get_u8(),
nomenclature_version: buf.get_u8(),
nomenclature: buf.get_u16(),
}
}
}