Skip to main content

hydr_core/capability/
component.rs

1//! Identity of each component that declares capabilities.
2
3/// Component that declares capabilities.
4#[derive(Clone, Copy, Debug, PartialEq, Eq)]
5#[non_exhaustive]
6pub enum ComponentId {
7    /// 2D shallow-water surface solver.
8    SurfaceSolver,
9    /// Opt-in 2D shallow-water surface solver running in F32 (CPU, CUDA, and WGPU).
10    SurfaceSolverF32,
11    /// Channel reach with a rectangular cross-section.
12    ChannelReachRectangular,
13    /// Channel reach with a triangular cross-section.
14    ChannelReachTriangular,
15    /// Channel reach with a surveyed cross-section.
16    ChannelReachSurveyed,
17    /// Channel reaches joined through pools.
18    ChannelPools,
19    /// Single level-pool storage.
20    LevelPool,
21    /// Level pools joined through connections.
22    CoupledLevelPools,
23    /// Runoff routed into pools.
24    RunoffPools,
25    /// Reservoir storage.
26    Reservoir,
27    /// Subcatchment runoff generator.
28    Subcatchment,
29    /// Soil infiltration model.
30    Soil,
31    /// Control logic that sets structure operation.
32    OperatingControl,
33    /// Actuator that moves a gate opening.
34    GateActuator,
35    /// Gate under operating control.
36    ControlledGate,
37    /// Pump under operating control.
38    ControlledPump,
39    /// 2D surface coupled to channel reaches through lateral bank weirs.
40    SurfaceChannels,
41    /// Closed-conduit culvert barrel geometry for circular and box barrels.
42    CulvertBarrel,
43    /// HDS-5 inlet-control headwater of circular and box culverts.
44    CulvertInlet,
45    /// Outlet-control headwater and hydraulic jump of circular and box culverts.
46    CulvertOutlet,
47    /// HDS-5 culvert structure law: discharge from the heads at both ends.
48    Culvert,
49    /// Pinned EPA SWMM v5.2.4 piped drainage network solver.
50    SwmmDrainage,
51    /// 2D surface coupled to a pinned EPA SWMM v5.2.4 piped drainage network.
52    SurfaceDrainage,
53    /// 2D surface simultaneously coupled to 1D channels/pools/structures and pinned EPA SWMM v5.2.4 piped drainage.
54    SurfaceChannelDrainage,
55    /// Pure-Rust 1D dynamic-wave Preissmann-slot pressurized-pipe drainage network solver.
56    NativePipeDrainage,
57}
58
59impl ComponentId {
60    /// Returns the stable kebab-case id. Persisted decisions store it, so it never changes.
61    pub fn id(&self) -> &'static str {
62        match self {
63            Self::SurfaceSolver => "surface-solver",
64            Self::SurfaceSolverF32 => "surface-solver-f32",
65            Self::ChannelReachRectangular => "channel-reach-rectangular",
66            Self::ChannelReachTriangular => "channel-reach-triangular",
67            Self::ChannelReachSurveyed => "channel-reach-surveyed",
68            Self::ChannelPools => "channel-pools",
69            Self::LevelPool => "level-pool",
70            Self::CoupledLevelPools => "coupled-level-pools",
71            Self::RunoffPools => "runoff-pools",
72            Self::Reservoir => "reservoir",
73            Self::Subcatchment => "subcatchment",
74            Self::Soil => "soil",
75            Self::OperatingControl => "operating-control",
76            Self::GateActuator => "gate-actuator",
77            Self::ControlledGate => "controlled-gate",
78            Self::ControlledPump => "controlled-pump",
79            Self::SurfaceChannels => "surface-channels",
80            Self::CulvertBarrel => "culvert-barrel",
81            Self::CulvertInlet => "culvert-inlet",
82            Self::CulvertOutlet => "culvert-outlet",
83            Self::Culvert => "culvert",
84            Self::SwmmDrainage => "swmm-drainage",
85            Self::SurfaceDrainage => "surface-drainage",
86            Self::SurfaceChannelDrainage => "surface-channel-drainage",
87            Self::NativePipeDrainage => "native-pipe-drainage",
88        }
89    }
90}
91
92#[cfg(test)]
93mod tests {
94    use super::*;
95    use crate::capability::id_check::assert_ids;
96
97    #[test]
98    fn ids_are_unique_kebab_case() {
99        let all = [
100            ComponentId::SurfaceSolver,
101            ComponentId::SurfaceSolverF32,
102            ComponentId::ChannelReachRectangular,
103            ComponentId::ChannelReachTriangular,
104            ComponentId::ChannelReachSurveyed,
105            ComponentId::ChannelPools,
106            ComponentId::LevelPool,
107            ComponentId::CoupledLevelPools,
108            ComponentId::RunoffPools,
109            ComponentId::Reservoir,
110            ComponentId::Subcatchment,
111            ComponentId::Soil,
112            ComponentId::OperatingControl,
113            ComponentId::GateActuator,
114            ComponentId::ControlledGate,
115            ComponentId::ControlledPump,
116            ComponentId::SurfaceChannels,
117            ComponentId::CulvertBarrel,
118            ComponentId::CulvertInlet,
119            ComponentId::CulvertOutlet,
120            ComponentId::Culvert,
121            ComponentId::SwmmDrainage,
122            ComponentId::SurfaceDrainage,
123            ComponentId::SurfaceChannelDrainage,
124            ComponentId::NativePipeDrainage,
125        ];
126        assert_ids(&all.map(|c| c.id()));
127    }
128}