1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//     dis-rust - A rust implementation of the DIS simulation protocol.
//     Copyright (C) 2022 Thomas Mann
// 
//     This software is dual-licensed. It is available under the conditions of
//     the GNU Affero General Public License (see the LICENSE file included) 
//     or under a commercial license (email contact@coffeebreakdevs.com for
//     details).

use bytes::BytesMut;

use super::dis_error::DISError;

/// Trait to denote a PDU.
pub trait PDU {
    /// Fills a BytesMut struct with a PDU serialised into binary. This buffer is then ready to be sent via
    /// UDP to the simluation network.
    fn serialise(&self, buf: &mut BytesMut); 

    /// Creates a PDU from a BytesMut struct.
    fn deserialise(buffer: BytesMut) -> Result<Self, DISError> where Self: Sized;
}