dis_rs/common/data/
builder.rs

1use crate::common::data::model::Data;
2use crate::common::model::{EntityId, FixedDatum, VariableDatum};
3
4pub struct DataBuilder(Data);
5
6impl Default for DataBuilder {
7    fn default() -> Self {
8        Self::new()
9    }
10}
11
12impl DataBuilder {
13    #[must_use]
14    pub fn new() -> Self {
15        DataBuilder(Data::default())
16    }
17
18    #[must_use]
19    pub fn new_from_body(body: Data) -> Self {
20        DataBuilder(body)
21    }
22
23    #[must_use]
24    pub fn build(self) -> Data {
25        self.0
26    }
27
28    #[must_use]
29    pub fn with_origination_id(mut self, originating_id: EntityId) -> Self {
30        self.0.originating_id = originating_id;
31        self
32    }
33
34    #[must_use]
35    pub fn with_receiving_id(mut self, receiving_id: EntityId) -> Self {
36        self.0.receiving_id = receiving_id;
37        self
38    }
39
40    #[must_use]
41    pub fn with_request_id(mut self, request_id: u32) -> Self {
42        self.0.request_id = request_id;
43        self
44    }
45
46    #[must_use]
47    pub fn with_fixed_datums(mut self, fixed_datum_records: Vec<FixedDatum>) -> Self {
48        self.0.fixed_datum_records = fixed_datum_records;
49        self
50    }
51
52    #[must_use]
53    pub fn with_variable_datums(mut self, variable_datum_records: Vec<VariableDatum>) -> Self {
54        self.0.variable_datum_records = variable_datum_records;
55        self
56    }
57}