edifact_primitives/
control.rs1#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
6pub enum Control {
7 #[default]
9 Continue,
10 Stop,
12}
13
14impl Control {
15 pub fn should_continue(&self) -> bool {
17 matches!(self, Self::Continue)
18 }
19
20 pub fn should_stop(&self) -> bool {
22 matches!(self, Self::Stop)
23 }
24}
25
26#[cfg(test)]
27mod tests {
28 use super::*;
29
30 #[test]
31 fn test_control_continue() {
32 let c = Control::Continue;
33 assert!(c.should_continue());
34 assert!(!c.should_stop());
35 }
36
37 #[test]
38 fn test_control_stop() {
39 let c = Control::Stop;
40 assert!(c.should_stop());
41 assert!(!c.should_continue());
42 }
43
44 #[test]
45 fn test_control_default_is_continue() {
46 assert_eq!(Control::default(), Control::Continue);
47 }
48
49 #[test]
50 fn test_control_equality() {
51 assert_eq!(Control::Continue, Control::Continue);
52 assert_eq!(Control::Stop, Control::Stop);
53 assert_ne!(Control::Continue, Control::Stop);
54 }
55}