1#[derive(Debug, Clone, Copy, PartialEq, Eq)]
2pub enum TraceKind {
3 Operation,
4 Request,
5 Relation,
6 Entity,
7 Provider,
8 Sql,
9 Comment,
10 Purpose,
11 AuditReason,
12}
13
14#[derive(Debug, Clone, PartialEq, Eq)]
15pub struct TraceNode {
16 pub kind: TraceKind,
17 pub entity_type: String,
18 pub entity_id: Option<u64>,
19 pub comment: String,
20}
21
22impl TraceNode {
23 pub fn new(
24 entity_type: impl Into<String>,
25 entity_id: Option<u64>,
26 comment: impl Into<String>,
27 ) -> Self {
28 Self {
29 kind: TraceKind::Entity,
30 entity_type: entity_type.into(),
31 entity_id,
32 comment: comment.into(),
33 }
34 }
35
36 pub fn typed(
37 kind: TraceKind,
38 name: impl Into<String>,
39 entity_id: Option<u64>,
40 value: impl Into<String>,
41 ) -> Self {
42 Self {
43 kind,
44 entity_type: name.into(),
45 entity_id,
46 comment: value.into(),
47 }
48 }
49}