dis_rs/common/record_r/
builder.rs

1use crate::common::model::{EntityId, RecordSpecification};
2use crate::enumerations::{EventType, RequiredReliabilityService};
3use crate::record_r::model::RecordR;
4
5pub struct RecordRBuilder(RecordR);
6
7impl Default for RecordRBuilder {
8    fn default() -> Self {
9        Self::new()
10    }
11}
12
13impl RecordRBuilder {
14    #[must_use]
15    pub fn new() -> Self {
16        RecordRBuilder(RecordR::default())
17    }
18
19    #[must_use]
20    pub fn new_from_body(body: RecordR) -> Self {
21        RecordRBuilder(body)
22    }
23
24    #[must_use]
25    pub fn build(self) -> RecordR {
26        self.0
27    }
28
29    #[must_use]
30    pub fn with_origination_id(mut self, originating_id: EntityId) -> Self {
31        self.0.originating_id = originating_id;
32        self
33    }
34
35    #[must_use]
36    pub fn with_receiving_id(mut self, receiving_id: EntityId) -> Self {
37        self.0.receiving_id = receiving_id;
38        self
39    }
40
41    #[must_use]
42    pub fn with_request_id(mut self, request_id: u32) -> Self {
43        self.0.request_id = request_id;
44        self
45    }
46
47    #[must_use]
48    pub fn with_required_reliability_service(
49        mut self,
50        required_reliability_service: RequiredReliabilityService,
51    ) -> Self {
52        self.0.required_reliability_service = required_reliability_service;
53        self
54    }
55
56    #[must_use]
57    pub fn with_event_type(mut self, event_type: EventType) -> Self {
58        self.0.event_type = event_type;
59        self
60    }
61
62    #[must_use]
63    pub fn with_response_serial_number(mut self, response_serial_number: u32) -> Self {
64        self.0.response_serial_number = response_serial_number;
65        self
66    }
67
68    #[must_use]
69    pub fn with_record_specification(mut self, record_specification: RecordSpecification) -> Self {
70        self.0.record_specification = record_specification;
71        self
72    }
73}