sui_rpc/proto/sui/rpc/v2beta2/
epoch.rs1use super::*;
2use crate::field::FieldMaskTree;
3use crate::merge::Merge;
4
5impl Merge<&Epoch> for Epoch {
6 fn merge(&mut self, source: &Epoch, mask: &FieldMaskTree) {
7 let Epoch {
8 epoch,
9 committee,
10 system_state,
11 first_checkpoint,
12 last_checkpoint,
13 start,
14 end,
15 reference_gas_price,
16 protocol_config,
17 } = source;
18
19 if mask.contains(Self::EPOCH_FIELD.name) {
20 self.epoch = *epoch;
21 }
22
23 if mask.contains(Self::COMMITTEE_FIELD.name) {
24 self.committee = committee.to_owned();
25 }
26
27 if mask.contains(Self::SYSTEM_STATE_FIELD.name) {
28 self.system_state = system_state.to_owned();
29 }
30
31 if mask.contains(Self::FIRST_CHECKPOINT_FIELD.name) {
32 self.first_checkpoint = first_checkpoint.to_owned();
33 }
34
35 if mask.contains(Self::LAST_CHECKPOINT_FIELD.name) {
36 self.last_checkpoint = last_checkpoint.to_owned();
37 }
38
39 if mask.contains(Self::START_FIELD.name) {
40 self.start = start.to_owned();
41 }
42
43 if mask.contains(Self::END_FIELD.name) {
44 self.end = end.to_owned();
45 }
46
47 if mask.contains(Self::REFERENCE_GAS_PRICE_FIELD.name) {
48 self.reference_gas_price = reference_gas_price.to_owned();
49 }
50
51 if let Some(submask) = mask.subtree(Self::PROTOCOL_CONFIG_FIELD.name) {
52 self.protocol_config = protocol_config
53 .as_ref()
54 .map(|config| ProtocolConfig::merge_from(config, &submask));
55 }
56 }
57}
58
59impl Merge<&ProtocolConfig> for ProtocolConfig {
60 fn merge(&mut self, source: &ProtocolConfig, mask: &FieldMaskTree) {
61 let ProtocolConfig {
62 protocol_version,
63 feature_flags,
64 attributes,
65 } = source;
66
67 if mask.contains(Self::PROTOCOL_VERSION_FIELD.name) {
68 self.protocol_version = *protocol_version;
69 }
70
71 if mask.contains(Self::FEATURE_FLAGS_FIELD.name) {
72 self.feature_flags = feature_flags.to_owned();
73 }
74
75 if mask.contains(Self::ATTRIBUTES_FIELD.name) {
76 self.attributes = attributes.to_owned();
77 }
78 }
79}
80
81impl Merge<ProtocolConfig> for ProtocolConfig {
82 fn merge(&mut self, source: ProtocolConfig, mask: &FieldMaskTree) {
83 let ProtocolConfig {
84 protocol_version,
85 feature_flags,
86 attributes,
87 } = source;
88
89 if mask.contains(Self::PROTOCOL_VERSION_FIELD.name) {
90 self.protocol_version = protocol_version;
91 }
92
93 if mask.contains(Self::FEATURE_FLAGS_FIELD.name) {
94 self.feature_flags = feature_flags;
95 }
96
97 if mask.contains(Self::ATTRIBUTES_FIELD.name) {
98 self.attributes = attributes;
99 }
100 }
101}