1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
use chrono::NaiveDateTime;
use std::path::Path;
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub enum EventType {
Exec,
ExecDone,
Read,
Write,
Miss,
}
#[derive(Debug)]
pub enum EventData<'a> {
Exec {
content: &'a str,
args: &'a str,
dir: Option<&'a Path>,
},
ExecDone {
code: i32,
main_event_id: i64,
},
Read,
Write,
Miss,
}
impl EventData<'_> {
pub fn get_type(&self) -> EventType {
match self {
EventData::Exec { .. } => EventType::Exec,
EventData::ExecDone { .. } => EventType::ExecDone,
EventData::Read => EventType::Read,
EventData::Write => EventType::Write,
EventData::Miss => EventType::Miss,
}
}
}
impl EventType {
pub const fn get_code(&self) -> i8 {
use EventType::*;
match self {
Read => 0,
Write => 1,
Miss => 2,
Exec => 3,
ExecDone => 4,
}
}
}
#[derive(Debug)]
pub struct Event<'a> {
pub data: EventData<'a>,
pub script_id: i64,
pub time: NaiveDateTime,
pub humble: bool,
}