dis_rs/common/action_response/
builder.rs

1use crate::common::action_response::model::ActionResponse;
2use crate::common::model::{EntityId, FixedDatum, VariableDatum};
3use crate::enumerations::RequestStatus;
4
5pub struct ActionResponseBuilder(ActionResponse);
6
7impl Default for ActionResponseBuilder {
8    fn default() -> Self {
9        Self::new()
10    }
11}
12
13impl ActionResponseBuilder {
14    #[must_use]
15    pub fn new() -> Self {
16        ActionResponseBuilder(ActionResponse::default())
17    }
18
19    #[must_use]
20    pub fn new_from_body(body: ActionResponse) -> Self {
21        ActionResponseBuilder(body)
22    }
23
24    #[must_use]
25    pub fn build(self) -> ActionResponse {
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_request_status(mut self, request_status: RequestStatus) -> Self {
49        self.0.request_status = request_status;
50        self
51    }
52
53    #[must_use]
54    pub fn with_fixed_datums(mut self, fixed_datum_records: Vec<FixedDatum>) -> Self {
55        self.0.fixed_datum_records = fixed_datum_records;
56        self
57    }
58
59    #[must_use]
60    pub fn with_variable_datums(mut self, variable_datum_records: Vec<VariableDatum>) -> Self {
61        self.0.variable_datum_records = variable_datum_records;
62        self
63    }
64}