1use crate::error::StateTransition;
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq)]
5pub enum NetworkState {
6 Unconfigured,
8 Configuring,
10 Active,
12 Cleaned,
14}
15
16impl StateTransition for NetworkState {
17 fn can_transition_to(&self, next: &NetworkState) -> bool {
18 matches!(
19 (self, next),
20 (NetworkState::Unconfigured, NetworkState::Configuring)
21 | (NetworkState::Configuring, NetworkState::Active)
22 | (NetworkState::Active, NetworkState::Cleaned)
23 )
24 }
25
26 fn is_terminal(&self) -> bool {
27 matches!(self, NetworkState::Cleaned)
28 }
29}