component_runtime/
policy.rs

1use std::sync::Arc;
2
3use component_store::ComponentStore;
4use component_store::VerificationPolicy;
5
6#[derive(Debug, Clone)]
7pub struct HostPolicy {
8    pub allow_http_fetch: bool,
9    pub allow_telemetry: bool,
10}
11
12impl Default for HostPolicy {
13    fn default() -> Self {
14        Self {
15            allow_http_fetch: false,
16            allow_telemetry: true,
17        }
18    }
19}
20
21#[derive(Debug, Clone)]
22pub struct LoadPolicy {
23    pub store: Arc<ComponentStore>,
24    pub verification: VerificationPolicy,
25    pub host: HostPolicy,
26}
27
28impl LoadPolicy {
29    pub fn new(store: Arc<ComponentStore>) -> Self {
30        Self {
31            store,
32            verification: VerificationPolicy::default(),
33            host: HostPolicy::default(),
34        }
35    }
36
37    pub fn with_verification(mut self, policy: VerificationPolicy) -> Self {
38        self.verification = policy;
39        self
40    }
41
42    pub fn with_host_policy(mut self, host: HostPolicy) -> Self {
43        self.host = host;
44        self
45    }
46}