dis-rs 0.13.0

An implementation of the Distributed Interactive Simulation protocol (IEEE-1278.1) in Rust. This main crate contains PDU implementations and facilities to read/write PDUs from Rust data structures to the wire format and vice versa. It supports versions 6 and 7 of the protocol.
Documentation
use crate::common::entity_state_update::model::EntityStateUpdate;
use crate::common::{Serialize, SerializePdu, SupportedVersion};
use bytes::{BufMut, BytesMut};

impl SerializePdu for EntityStateUpdate {
    fn serialize_pdu(&self, _version: SupportedVersion, buf: &mut BytesMut) -> u16 {
        let entity_id_bytes = self.entity_id.serialize(buf);
        buf.put_u8(0u8);
        buf.put_u8(self.variable_parameters.len() as u8);
        let linear_velocity_bytes = self.entity_linear_velocity.serialize(buf);
        let location_bytes = self.entity_location.serialize(buf);
        let orientation_bytes = self.entity_orientation.serialize(buf);
        let appearance_bytes = self.entity_appearance.serialize(buf);
        let variable_params_bytes: u16 = self
            .variable_parameters
            .iter()
            .map(|param| param.serialize(buf))
            .sum();

        entity_id_bytes
            + 2
            + linear_velocity_bytes
            + location_bytes
            + orientation_bytes
            + appearance_bytes
            + variable_params_bytes
    }
}