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 websocket: TransportInstances<WebSocketConfig>,
33
34 #[serde(default, skip_serializing_if = "is_transport_empty")]
36 pub tor: TransportInstances<TorConfig>,
37
38 #[serde(default, skip_serializing_if = "is_transport_empty")]
40 pub webrtc: TransportInstances<WebRtcConfig>,
41
42 #[serde(default, skip_serializing_if = "is_transport_empty")]
44 pub ble: TransportInstances<BleConfig>,
45}
46
47fn is_transport_empty<T>(instances: &TransportInstances<T>) -> bool {
49 instances.is_empty()
50}
51
52impl TransportsConfig {
53 pub fn is_empty(&self) -> bool {
55 self.udp.is_empty()
56 && {
57 #[cfg(feature = "sim-transport")]
58 {
59 self.sim.is_empty()
60 }
61 #[cfg(not(feature = "sim-transport"))]
62 {
63 true
64 }
65 }
66 && self.ethernet.is_empty()
67 && self.tcp.is_empty()
68 && self.websocket.is_empty()
69 && self.tor.is_empty()
70 && self.webrtc.is_empty()
71 && self.ble.is_empty()
72 }
73
74 pub fn merge(&mut self, other: TransportsConfig) {
78 if !other.udp.is_empty() {
79 self.udp = other.udp;
80 }
81 #[cfg(feature = "sim-transport")]
82 if !other.sim.is_empty() {
83 self.sim = other.sim;
84 }
85 if !other.ethernet.is_empty() {
86 self.ethernet = other.ethernet;
87 }
88 if !other.tcp.is_empty() {
89 self.tcp = other.tcp;
90 }
91 if !other.websocket.is_empty() {
92 self.websocket = other.websocket;
93 }
94 if !other.tor.is_empty() {
95 self.tor = other.tor;
96 }
97 if !other.webrtc.is_empty() {
98 self.webrtc = other.webrtc;
99 }
100 if !other.ble.is_empty() {
101 self.ble = other.ble;
102 }
103 }
104}