pub trait AllocationPolicy {
type Error;
// Required methods
fn validate_key(&self, key: &StableKey) -> Result<(), Self::Error>;
fn validate_slot(
&self,
key: &StableKey,
slot: &MemoryManagerSlot,
) -> Result<(), Self::Error>;
fn validate_reserved_slot(
&self,
key: &StableKey,
slot: &MemoryManagerSlot,
) -> Result<(), Self::Error>;
}Expand description
AllocationPolicy
Framework-supplied rules for whether a key may claim a slot.
Policy is intentionally separate from the durable ledger invariant. The
ledger remembers stable_key -> allocation_slot; this trait lets an
integration reject declarations that do not belong to its namespace or
substrate-specific range before staging a generation.
crate::MemoryRuntime admits host namespace grants and physical pool
eligibility during resolution, before this policy’s validation callbacks.
These callbacks receive external declarations only; the internal
allocation-ledger declaration remains exclusively governed by ic-memory.
Framework policies may add restrictions within the host’s grants and pool;
they cannot expand the pool or replace host ownership admission.
Required Associated Types§
Required Methods§
Sourcefn validate_key(&self, key: &StableKey) -> Result<(), Self::Error>
fn validate_key(&self, key: &StableKey) -> Result<(), Self::Error>
Validate a stable key against framework naming rules.
Sourcefn validate_slot(
&self,
key: &StableKey,
slot: &MemoryManagerSlot,
) -> Result<(), Self::Error>
fn validate_slot( &self, key: &StableKey, slot: &MemoryManagerSlot, ) -> Result<(), Self::Error>
Validate a stable-key to allocation-slot claim. The slot already contains a usable ID; policy checks ownership and scope.
Sourcefn validate_reserved_slot(
&self,
key: &StableKey,
slot: &MemoryManagerSlot,
) -> Result<(), Self::Error>
fn validate_reserved_slot( &self, key: &StableKey, slot: &MemoryManagerSlot, ) -> Result<(), Self::Error>
Validate a reserved stable-key to allocation-slot claim. The checked slot does not establish permission to reserve that ID.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".