#[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,
}
}
}