scratchstack_aspen/
effect.rs1use {
2 serde::{Deserialize, Serialize},
3 std::fmt::{Display, Formatter, Result as FmtResult},
4};
5
6#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
8pub enum Effect {
9 Allow,
11
12 Deny,
14}
15
16impl Display for Effect {
17 fn fmt(&self, f: &mut Formatter) -> FmtResult {
18 match self {
19 Self::Allow => f.write_str("Allow"),
20 Self::Deny => f.write_str("Deny"),
21 }
22 }
23}
24
25#[cfg(test)]
26mod tests {
27 use {crate::Effect, pretty_assertions::assert_eq, std::collections::HashMap};
28
29 #[test_log::test]
30 fn test_hash() {
31 let mut hash_map = HashMap::new();
32 hash_map.insert(Effect::Allow, 1);
33 hash_map.insert(Effect::Deny, 2);
34
35 assert_eq!(hash_map.get(&Effect::Allow), Some(&1));
36 assert_eq!(hash_map.get(&Effect::Deny), Some(&2));
37 }
38
39 #[test_log::test]
40 fn test_display() {
41 assert_eq!(format!("{}", Effect::Allow), "Allow");
42 assert_eq!(format!("{}", Effect::Deny), "Deny");
43 }
44}