cratestack_policy/
procedure_types.rs1use cratestack_core::Value;
4
5#[derive(Debug, Clone, Copy, PartialEq, Eq)]
6pub enum ProcedurePolicyLiteral {
7 Bool(bool),
8 Int(i64),
9 String(&'static str),
10}
11
12#[derive(Debug, Clone, Copy, PartialEq, Eq)]
13pub enum ProcedurePredicate {
14 AuthNotNull,
15 AuthIsNull,
16 HasRole {
17 role: &'static str,
18 },
19 InTenant {
20 tenant_id: &'static str,
21 },
22 AuthFieldEqLiteral {
23 auth_field: &'static str,
24 value: ProcedurePolicyLiteral,
25 },
26 AuthFieldNeLiteral {
27 auth_field: &'static str,
28 value: ProcedurePolicyLiteral,
29 },
30 InputFieldIsTrue {
31 field: &'static str,
32 },
33 InputFieldEqLiteral {
34 field: &'static str,
35 value: ProcedurePolicyLiteral,
36 },
37 InputFieldNeLiteral {
38 field: &'static str,
39 value: ProcedurePolicyLiteral,
40 },
41 InputFieldEqAuth {
42 field: &'static str,
43 auth_field: &'static str,
44 },
45 InputFieldNeAuth {
46 field: &'static str,
47 auth_field: &'static str,
48 },
49 InputFieldEqInput {
50 field: &'static str,
51 other_field: &'static str,
52 },
53 InputFieldNeInput {
54 field: &'static str,
55 other_field: &'static str,
56 },
57}
58
59#[derive(Debug, Clone, Copy, PartialEq, Eq)]
60pub struct ProcedurePolicy {
61 pub expr: ProcedurePolicyExpr,
62}
63
64#[derive(Debug, Clone, Copy, PartialEq, Eq)]
65pub enum ProcedurePolicyExpr {
66 Predicate(ProcedurePredicate),
67 And(&'static [ProcedurePolicyExpr]),
68 Or(&'static [ProcedurePolicyExpr]),
69}
70
71pub trait ProcedureArgs {
72 fn procedure_arg_value(&self, field: &str) -> Option<Value>;
73}
74
75impl ProcedureArgs for () {
76 fn procedure_arg_value(&self, _field: &str) -> Option<Value> {
77 None
78 }
79}