1#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
2pub enum ViolationSource {
3 Read,
4 Write,
5 ReadVia,
6 WriteVia,
7}
8
9pub enum HookInvalidAccessAction<R, V> {
10 Pass,
11 Skip, Halt(R),
13 Value(Vec<V>), }
15
16impl<R, V> HookInvalidAccessAction<R, V> {
17 pub fn is_value(&self) -> bool {
18 matches!(self, Self::Value(_))
19 }
20
21 pub fn is_halt(&self) -> bool {
22 matches!(self, Self::Halt(_))
23 }
24
25 pub fn is_pass(&self) -> bool {
26 matches!(self, Self::Pass)
27 }
28
29 pub fn is_skip(&self) -> bool {
30 matches!(self, Self::Skip)
31 }
32
33 pub fn value(&self) -> Option<&[V]> {
34 if let Self::Value(ref v) = self {
35 Some(v)
36 } else {
37 None
38 }
39 }
40
41 pub fn into_value(self) -> Option<Vec<V>> {
42 if let Self::Value(v) = self {
43 Some(v)
44 } else {
45 None
46 }
47 }
48
49 pub fn unwrap_value(self) -> Vec<V> {
50 self.into_value().unwrap()
51 }
52}