Skip to main content

AllocationPolicy

Trait AllocationPolicy 

Source
pub trait AllocationPolicy {
    type Error;

    // Required methods
    fn validate_key(&self, key: &StableKey) -> Result<(), Self::Error>;
    fn validate_slot(
        &self,
        key: &StableKey,
        slot: &AllocationSlotDescriptor,
    ) -> Result<(), Self::Error>;
    fn validate_reserved_slot(
        &self,
        key: &StableKey,
        slot: &AllocationSlotDescriptor,
    ) -> 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.

In the default MemoryManager runtime, registered range claims are checked before this policy, and this policy receives external declarations only. The internal allocation-ledger declaration remains exclusively governed by ic-memory. Framework adapters should decide whether registered range claims or their own policy is authoritative for application ID space, then register ranges accordingly.

Required Associated Types§

Source

type Error

Policy error type.

Required Methods§

Source

fn validate_key(&self, key: &StableKey) -> Result<(), Self::Error>

Validate a stable key against framework naming rules.

Source

fn validate_slot( &self, key: &StableKey, slot: &AllocationSlotDescriptor, ) -> Result<(), Self::Error>

Validate a stable-key to allocation-slot claim.

Source

fn validate_reserved_slot( &self, key: &StableKey, slot: &AllocationSlotDescriptor, ) -> Result<(), Self::Error>

Validate a reserved stable-key to allocation-slot claim.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§