use bytes::{BytesMut, BufMut, Buf};
use serde::{Serialize, Deserialize};
#[derive(Copy, Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct SimulationAddressRecord {
pub site_identifier_field: u16,
pub application_identifier_field: u16
}
impl SimulationAddressRecord {
pub fn new(site_identifier_field: u16, application_identifier_field: u16) -> Self {
if site_identifier_field == 0{
println!("Invalid site identifier field! - cannot be 0"); }
if application_identifier_field == 0{
println!("Invalid application identifier field! - cannot be 0"); }
SimulationAddressRecord {
site_identifier_field,
application_identifier_field
}
}
pub fn default() -> Self {
SimulationAddressRecord {
site_identifier_field: 1,
application_identifier_field: 1
}
}
pub fn serialize(&self, buf: &mut BytesMut) {
buf.put_u16(self.site_identifier_field);
buf.put_u16(self.application_identifier_field);
}
pub fn decode(buf: &mut BytesMut) -> SimulationAddressRecord {
SimulationAddressRecord {
site_identifier_field: buf.get_u16(),
application_identifier_field: buf.get_u16(),
}
}
}