dis_rs/common/stop_freeze/
model.rs

1use crate::common::model::{ClockTime, EntityId, PduBody};
2use crate::common::{BodyInfo, Interaction};
3use crate::enumerations::{PduType, StopFreezeFrozenBehavior, StopFreezeReason};
4use crate::stop_freeze::builder::StopFreezeBuilder;
5#[cfg(feature = "serde")]
6use serde::{Deserialize, Serialize};
7
8const STOP_FREEZE_BODY_LENGTH: u16 = 28;
9
10/// 5.6.5.5 Stop/Freeze PDU
11///
12/// 7.5.5 Stop/Freeze PDU
13#[derive(Clone, Debug, Default, PartialEq)]
14#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
15pub struct StopFreeze {
16    pub originating_id: EntityId,
17    pub receiving_id: EntityId,
18    pub real_world_time: ClockTime,
19    pub reason: StopFreezeReason,
20    pub frozen_behavior: StopFreezeFrozenBehavior,
21    pub request_id: u32,
22}
23
24impl StopFreeze {
25    #[must_use]
26    pub fn builder() -> StopFreezeBuilder {
27        StopFreezeBuilder::new()
28    }
29
30    #[must_use]
31    pub fn into_builder(self) -> StopFreezeBuilder {
32        StopFreezeBuilder::new_from_body(self)
33    }
34
35    #[must_use]
36    pub fn into_pdu_body(self) -> PduBody {
37        PduBody::StopFreeze(self)
38    }
39}
40
41impl BodyInfo for StopFreeze {
42    fn body_length(&self) -> u16 {
43        STOP_FREEZE_BODY_LENGTH
44    }
45
46    fn body_type(&self) -> PduType {
47        PduType::StopFreeze
48    }
49}
50
51impl Interaction for StopFreeze {
52    fn originator(&self) -> Option<&EntityId> {
53        Some(&self.originating_id)
54    }
55
56    fn receiver(&self) -> Option<&EntityId> {
57        Some(&self.receiving_id)
58    }
59}