dis_rs/common/create_entity/
model.rs1use crate::BodyRaw;
2use crate::common::create_entity::builder::CreateEntityBuilder;
3use crate::common::model::{EntityId, PduBody};
4use crate::common::{BodyInfo, Interaction};
5use crate::enumerations::PduType;
6#[cfg(feature = "serde")]
7use serde::{Deserialize, Serialize};
8
9const CREATE_ENTITY_BODY_LENGTH: u16 = 16;
10
11#[derive(Clone, Debug, Default, PartialEq)]
15#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
16pub struct CreateEntity {
17 pub originating_id: EntityId,
18 pub receiving_id: EntityId,
19 pub request_id: u32,
20}
21
22impl BodyRaw for CreateEntity {
23 type Builder = CreateEntityBuilder;
24
25 fn builder() -> CreateEntityBuilder {
26 CreateEntityBuilder::new()
27 }
28
29 fn into_builder(self) -> CreateEntityBuilder {
30 CreateEntityBuilder::new_from_body(self)
31 }
32
33 fn into_pdu_body(self) -> PduBody {
34 PduBody::CreateEntity(self)
35 }
36}
37
38impl BodyInfo for CreateEntity {
39 fn body_length(&self) -> u16 {
40 CREATE_ENTITY_BODY_LENGTH
41 }
42
43 fn body_type(&self) -> PduType {
44 PduType::CreateEntity
45 }
46}
47
48impl Interaction for CreateEntity {
49 fn originator(&self) -> Option<&EntityId> {
50 Some(&self.originating_id)
51 }
52
53 fn receiver(&self) -> Option<&EntityId> {
54 Some(&self.receiving_id)
55 }
56}