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::model::{ClockTime, EntityId, PduBody};
use crate::common::{BodyInfo, Interaction};
use crate::enumerations::{PduType, StopFreezeFrozenBehavior, StopFreezeReason};
use crate::stop_freeze::builder::StopFreezeBuilder;
use crate::BodyRaw;
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};

const STOP_FREEZE_BODY_LENGTH: u16 = 28;

/// 5.6.5.5 Stop/Freeze PDU
///
/// 7.5.5 Stop/Freeze PDU
#[derive(Clone, Debug, Default, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct StopFreeze {
    pub originating_id: EntityId,
    pub receiving_id: EntityId,
    pub real_world_time: ClockTime,
    pub reason: StopFreezeReason,
    pub frozen_behavior: StopFreezeFrozenBehavior,
    pub request_id: u32,
}

impl BodyRaw for StopFreeze {
    type Builder = StopFreezeBuilder;

    fn builder() -> Self::Builder {
        Self::Builder::new()
    }

    fn into_builder(self) -> Self::Builder {
        Self::Builder::new_from_body(self)
    }

    fn into_pdu_body(self) -> PduBody {
        PduBody::StopFreeze(self)
    }
}

impl BodyInfo for StopFreeze {
    fn body_length(&self) -> u16 {
        STOP_FREEZE_BODY_LENGTH
    }

    fn body_type(&self) -> PduType {
        PduType::StopFreeze
    }
}

impl Interaction for StopFreeze {
    fn originator(&self) -> Option<&EntityId> {
        Some(&self.originating_id)
    }

    fn receiver(&self) -> Option<&EntityId> {
        Some(&self.receiving_id)
    }
}