1#[derive(Clone, Copy, Debug, PartialEq, Eq)]
5#[non_exhaustive]
6pub enum EndpointId {
7 ExteriorFace,
9 ReachLeft,
11 ReachRight,
13 PoolConnection,
15 StructureEndpoint,
17 Outlet,
19 Lateral,
21 SurfaceCell,
23}
24
25impl EndpointId {
26 pub fn id(&self) -> &'static str {
28 match self {
29 Self::ExteriorFace => "exterior-face",
30 Self::ReachLeft => "reach-left",
31 Self::ReachRight => "reach-right",
32 Self::PoolConnection => "pool-connection",
33 Self::StructureEndpoint => "structure-endpoint",
34 Self::Outlet => "outlet",
35 Self::Lateral => "lateral",
36 Self::SurfaceCell => "surface-cell",
37 }
38 }
39}
40
41#[derive(Clone, Copy, Debug, PartialEq, Eq)]
43#[non_exhaustive]
44pub enum BoundaryKind {
45 Wall,
47 FluxPort,
49 Stage,
51 Discharge,
53 Exterior,
55 Transmissive,
57 QuiescentReservoir,
59 PoolConnection,
61 SubmergedOrifice,
63 SuppressedRectangularWeir,
65 PumpStoppedIsolated,
67 PumpRunning,
69 GateFixedOpening,
71 GatePrescribedOpening,
73 GateActuatedOpening,
75 PumpSampledControl,
77 PrescribedInflowRate,
79 PrescribedInflowVolume,
81 RunoffOutletNoFeedback,
83 Culvert,
85}
86
87impl BoundaryKind {
88 pub fn id(&self) -> &'static str {
90 match self {
91 Self::Wall => "wall",
92 Self::FluxPort => "flux-port",
93 Self::Stage => "stage",
94 Self::Discharge => "discharge",
95 Self::Exterior => "exterior",
96 Self::Transmissive => "transmissive",
97 Self::QuiescentReservoir => "quiescent-reservoir",
98 Self::PoolConnection => "pool-connection",
99 Self::SubmergedOrifice => "submerged-orifice",
100 Self::SuppressedRectangularWeir => "suppressed-rectangular-weir",
101 Self::PumpStoppedIsolated => "pump-stopped-isolated",
102 Self::PumpRunning => "pump-running",
103 Self::GateFixedOpening => "gate-fixed-opening",
104 Self::GatePrescribedOpening => "gate-prescribed-opening",
105 Self::GateActuatedOpening => "gate-actuated-opening",
106 Self::PumpSampledControl => "pump-sampled-control",
107 Self::PrescribedInflowRate => "prescribed-inflow-rate",
108 Self::PrescribedInflowVolume => "prescribed-inflow-volume",
109 Self::RunoffOutletNoFeedback => "runoff-outlet-no-feedback",
110 Self::Culvert => "culvert",
111 }
112 }
113}
114
115#[derive(Clone, Copy, Debug, PartialEq, Eq)]
117pub struct Endpoint {
118 pub id: EndpointId,
120 pub admitted: &'static [BoundaryKind],
122}
123
124impl Endpoint {
125 pub fn admits(&self, kind: BoundaryKind) -> bool {
127 self.admitted.contains(&kind)
128 }
129}
130
131#[cfg(test)]
132mod tests {
133 use super::*;
134 use crate::capability::id_check::assert_ids;
135
136 #[test]
137 fn endpoint_ids_are_unique_kebab_case() {
138 let all = [
139 EndpointId::ExteriorFace,
140 EndpointId::ReachLeft,
141 EndpointId::ReachRight,
142 EndpointId::PoolConnection,
143 EndpointId::StructureEndpoint,
144 EndpointId::Outlet,
145 EndpointId::Lateral,
146 EndpointId::SurfaceCell,
147 ];
148 assert_ids(&all.map(|e| e.id()));
149 }
150
151 #[test]
152 fn boundary_ids_are_unique_kebab_case() {
153 let all = [
154 BoundaryKind::Wall,
155 BoundaryKind::FluxPort,
156 BoundaryKind::Stage,
157 BoundaryKind::Discharge,
158 BoundaryKind::Exterior,
159 BoundaryKind::Transmissive,
160 BoundaryKind::QuiescentReservoir,
161 BoundaryKind::PoolConnection,
162 BoundaryKind::SubmergedOrifice,
163 BoundaryKind::SuppressedRectangularWeir,
164 BoundaryKind::PumpStoppedIsolated,
165 BoundaryKind::PumpRunning,
166 BoundaryKind::GateFixedOpening,
167 BoundaryKind::GatePrescribedOpening,
168 BoundaryKind::GateActuatedOpening,
169 BoundaryKind::PumpSampledControl,
170 BoundaryKind::PrescribedInflowRate,
171 BoundaryKind::PrescribedInflowVolume,
172 BoundaryKind::RunoffOutletNoFeedback,
173 BoundaryKind::Culvert,
174 ];
175 assert_ids(&all.map(|b| b.id()));
176 }
177
178 #[test]
179 fn controlled_structure_boundary_ids_are_frozen() {
180 for (kind, id) in [
181 (
182 BoundaryKind::GatePrescribedOpening,
183 "gate-prescribed-opening",
184 ),
185 (BoundaryKind::GateActuatedOpening, "gate-actuated-opening"),
186 (BoundaryKind::PumpSampledControl, "pump-sampled-control"),
187 ] {
188 assert_eq!(kind.id(), id);
189 }
190 }
191
192 #[test]
193 fn endpoint_admits_only_listed_kinds() {
194 let end = Endpoint {
195 id: EndpointId::ReachLeft,
196 admitted: &[BoundaryKind::Wall, BoundaryKind::Stage],
197 };
198 assert!(end.admits(BoundaryKind::Wall));
199 assert!(end.admits(BoundaryKind::Stage));
200 assert!(!end.admits(BoundaryKind::Discharge));
201 }
202}