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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#[derive(Debug, Copy, Clone, PartialEq)]
pub struct HostFnAccess {
pub agent_info: Permission,
pub read_workspace: Permission,
pub read_workspace_deterministic: Permission,
pub write_workspace: Permission,
pub write_network: Permission,
pub bindings: Permission,
pub bindings_deterministic: Permission,
pub non_determinism: Permission,
pub keystore: Permission,
pub keystore_deterministic: Permission,
}
#[derive(Debug, Copy, Clone, PartialEq)]
pub enum Permission {
Allow,
Deny,
}
impl HostFnAccess {
#[allow(clippy::too_many_arguments)]
pub fn new(
agent_info: Permission,
read_workspace: Permission,
read_workspace_deterministic: Permission,
write_workspace: Permission,
write_network: Permission,
bindings: Permission,
bindings_deterministic: Permission,
non_determinism: Permission,
keystore: Permission,
keystore_deterministic: Permission,
) -> Self {
Self {
agent_info,
read_workspace,
read_workspace_deterministic,
write_workspace,
write_network,
bindings,
bindings_deterministic,
non_determinism,
keystore,
keystore_deterministic,
}
}
pub fn all() -> Self {
HostFnAccess {
read_workspace: Permission::Allow,
read_workspace_deterministic: Permission::Allow,
write_workspace: Permission::Allow,
agent_info: Permission::Allow,
non_determinism: Permission::Allow,
write_network: Permission::Allow,
keystore: Permission::Allow,
keystore_deterministic: Permission::Allow,
bindings: Permission::Allow,
bindings_deterministic: Permission::Allow,
}
}
pub fn none() -> Self {
HostFnAccess {
read_workspace: Permission::Deny,
read_workspace_deterministic: Permission::Deny,
write_workspace: Permission::Deny,
agent_info: Permission::Deny,
non_determinism: Permission::Deny,
write_network: Permission::Deny,
keystore: Permission::Deny,
keystore_deterministic: Permission::Deny,
bindings: Permission::Deny,
bindings_deterministic: Permission::Deny,
}
}
}