pub struct AllocationDeclaration { /* private fields */ }Expand description
AllocationDeclaration
Checked runtime claim that a stable key should own an allocation slot.
Declarations are supplied by the current binary before opening storage. Constructors validate the stable key, label and schema metadata and accept an already checked slot. A declaration becomes authoritative only after validation against the recovered ledger and commitment in a generation.
Implementations§
Source§impl AllocationDeclaration
impl AllocationDeclaration
Sourcepub fn new(
stable_key: impl AsRef<str>,
slot: MemoryManagerSlot,
label: Option<String>,
schema: SchemaMetadata,
) -> Result<Self, DeclarationSnapshotError>
pub fn new( stable_key: impl AsRef<str>, slot: MemoryManagerSlot, label: Option<String>, schema: SchemaMetadata, ) -> Result<Self, DeclarationSnapshotError>
Build a declaration from raw parts after validating diagnostic metadata.
Sourcepub fn memory_manager(
stable_key: impl AsRef<str>,
id: u8,
label: impl Into<String>,
) -> Result<Self, DeclarationSnapshotError>
pub fn memory_manager( stable_key: impl AsRef<str>, id: u8, label: impl Into<String>, ) -> Result<Self, DeclarationSnapshotError>
Build a MemoryManager declaration with a diagnostic label.
Sourcepub fn memory_manager_unlabeled(
stable_key: impl AsRef<str>,
id: u8,
) -> Result<Self, DeclarationSnapshotError>
pub fn memory_manager_unlabeled( stable_key: impl AsRef<str>, id: u8, ) -> Result<Self, DeclarationSnapshotError>
Build an unlabeled MemoryManager declaration.
Sourcepub fn memory_manager_with_schema(
stable_key: impl AsRef<str>,
id: u8,
label: impl Into<String>,
schema: SchemaMetadata,
) -> Result<Self, DeclarationSnapshotError>
pub fn memory_manager_with_schema( stable_key: impl AsRef<str>, id: u8, label: impl Into<String>, schema: SchemaMetadata, ) -> Result<Self, DeclarationSnapshotError>
Build a MemoryManager declaration with a diagnostic label and schema metadata.
Sourcepub fn memory_manager_unlabeled_with_schema(
stable_key: impl AsRef<str>,
id: u8,
schema: SchemaMetadata,
) -> Result<Self, DeclarationSnapshotError>
pub fn memory_manager_unlabeled_with_schema( stable_key: impl AsRef<str>, id: u8, schema: SchemaMetadata, ) -> Result<Self, DeclarationSnapshotError>
Build an unlabeled MemoryManager declaration with schema metadata.
Sourcepub const fn stable_key(&self) -> &StableKey
pub const fn stable_key(&self) -> &StableKey
Return the durable stable key claimed by this declaration.
Sourcepub const fn slot(&self) -> &MemoryManagerSlot
pub const fn slot(&self) -> &MemoryManagerSlot
Return the allocation slot claimed by this declaration.
Sourcepub const fn schema(&self) -> &SchemaMetadata
pub const fn schema(&self) -> &SchemaMetadata
Return the optional schema metadata.
Sourcepub fn validate(&self) -> Result<(), DeclarationSnapshotError>
pub fn validate(&self) -> Result<(), DeclarationSnapshotError>
Validate constructor invariants after decode or manual assembly.