ic_memory/runtime/policy.rs
1use crate::{MemoryManagerSlot, PolicyIdentity, RuntimeBootstrapPolicy, StableKey};
2use std::convert::Infallible;
3
4///
5/// GenericAllocationPolicy
6///
7/// Built-in bootstrap policy for hosts needing no additional application checks.
8/// The runtime enforces host namespace grants, the common pool and governance;
9/// this policy adds no application-specific restrictions.
10///
11/// Use with configured bootstrap when the host does not require a custom
12/// policy. It retains the built-in policy identity and does not authorize
13/// replacing a different policy already bound to the runtime.
14///
15pub struct GenericAllocationPolicy;
16
17impl RuntimeBootstrapPolicy for GenericAllocationPolicy {
18 type Error = Infallible;
19
20 fn validate_allocation(
21 &self,
22 _key: &StableKey,
23 _slot: &MemoryManagerSlot,
24 ) -> Result<(), Self::Error> {
25 Ok(())
26 }
27
28 fn runtime_bootstrap_identity(&self) -> PolicyIdentity {
29 PolicyIdentity::new(*b"ic-memory.noop-policy...........")
30 }
31}