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
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use crate::common::Serialize;
use crate::v6::entity_state::model::EntityCapabilities;
use bytes::{BufMut, BytesMut};

impl Serialize for EntityCapabilities {
    fn serialize(&self, buf: &mut BytesMut) -> u16 {
        let ammunition_supply = u32::from(self.ammunition_supply) << 31;
        let fuel_supply = u32::from(self.fuel_supply) << 30;
        let recovery = u32::from(self.recovery) << 29;
        let repair = u32::from(self.repair) << 28;
        let capabilities = ammunition_supply | fuel_supply | recovery | repair;
        buf.put_u32(capabilities);
        4
    }
}