dis_rs/common/create_entity/
model.rs1use crate::common::create_entity::builder::CreateEntityBuilder;
2use crate::common::model::{EntityId, PduBody};
3use crate::common::{BodyInfo, Interaction};
4use crate::enumerations::PduType;
5#[cfg(feature = "serde")]
6use serde::{Deserialize, Serialize};
7
8const CREATE_ENTITY_BODY_LENGTH: u16 = 16;
9
10#[derive(Clone, Debug, Default, PartialEq)]
14#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
15pub struct CreateEntity {
16 pub originating_id: EntityId,
17 pub receiving_id: EntityId,
18 pub request_id: u32,
19}
20
21impl CreateEntity {
22 #[must_use]
23 pub fn builder() -> CreateEntityBuilder {
24 CreateEntityBuilder::new()
25 }
26
27 #[must_use]
28 pub fn into_builder(self) -> CreateEntityBuilder {
29 CreateEntityBuilder::new_from_body(self)
30 }
31
32 #[must_use]
33 pub 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}