open_dis_rust/common/
generic_header.rs

1//     open-dis-rust - Rust implementation of the IEEE 1278.1-2012 Distributed Interactive
2//                     Simulation (DIS) application protocol
3//     Copyright (C) 2025 Cameron Howell
4//
5//     Licensed under the BSD 2-Clause License
6
7use bytes::{Buf, BytesMut};
8
9use crate::common::enums::{PduType, ProtocolFamily};
10
11pub trait GenericHeader: Sized {
12    fn pdu_type(&self) -> PduType;
13    fn set_pdu_type(&mut self, value: PduType);
14
15    fn protocol_family(&self) -> ProtocolFamily;
16    fn set_protocol_family(&mut self, value: ProtocolFamily);
17
18    fn length(&self) -> u16;
19    fn set_length(&mut self, value: u16);
20
21    fn serialize(&self, buf: &mut BytesMut);
22    fn deserialize<B: Buf>(bug: &mut B) -> Self;
23}