fips_core/config/transport/
aggregate.rs1use super::*;
2
3#[derive(Debug, Clone, Default, Serialize, Deserialize)]
12pub struct TransportsConfig {
13 #[serde(default, skip_serializing_if = "is_transport_empty")]
15 pub udp: TransportInstances<UdpConfig>,
16
17 #[cfg(feature = "sim-transport")]
19 #[serde(default, skip_serializing_if = "is_transport_empty")]
20 pub sim: TransportInstances<SimTransportConfig>,
21
22 #[serde(default, skip_serializing_if = "is_transport_empty")]
24 pub ethernet: TransportInstances<EthernetConfig>,
25
26 #[serde(default, skip_serializing_if = "is_transport_empty")]
28 pub tcp: TransportInstances<TcpConfig>,
29
30 #[serde(default, skip_serializing_if = "is_transport_empty")]
32 pub tor: TransportInstances<TorConfig>,
33
34 #[serde(default, skip_serializing_if = "is_transport_empty")]
36 pub webrtc: TransportInstances<WebRtcConfig>,
37
38 #[serde(default, skip_serializing_if = "is_transport_empty")]
40 pub ble: TransportInstances<BleConfig>,
41}
42
43fn is_transport_empty<T>(instances: &TransportInstances<T>) -> bool {
45 instances.is_empty()
46}
47
48impl TransportsConfig {
49 pub fn is_empty(&self) -> bool {
51 self.udp.is_empty()
52 && {
53 #[cfg(feature = "sim-transport")]
54 {
55 self.sim.is_empty()
56 }
57 #[cfg(not(feature = "sim-transport"))]
58 {
59 true
60 }
61 }
62 && self.ethernet.is_empty()
63 && self.tcp.is_empty()
64 && self.tor.is_empty()
65 && self.webrtc.is_empty()
66 && self.ble.is_empty()
67 }
68
69 pub fn merge(&mut self, other: TransportsConfig) {
73 if !other.udp.is_empty() {
74 self.udp = other.udp;
75 }
76 #[cfg(feature = "sim-transport")]
77 if !other.sim.is_empty() {
78 self.sim = other.sim;
79 }
80 if !other.ethernet.is_empty() {
81 self.ethernet = other.ethernet;
82 }
83 if !other.tcp.is_empty() {
84 self.tcp = other.tcp;
85 }
86 if !other.tor.is_empty() {
87 self.tor = other.tor;
88 }
89 if !other.webrtc.is_empty() {
90 self.webrtc = other.webrtc;
91 }
92 if !other.ble.is_empty() {
93 self.ble = other.ble;
94 }
95 }
96}