Skip to main content

canic_core/memory/
registry.rs

1use thiserror::Error as ThisError;
2
3///
4/// MemoryRegistryError
5///
6/// Canic-facing errors returned while bootstrapping or reading the
7/// `ic-memory` allocation ledger.
8
9#[derive(Debug, ThisError)]
10pub enum MemoryRegistryError {
11    /// A declaration was rejected before or during `ic-memory` validation.
12    #[error("memory declaration rejected for stable key '{stable_key}': {reason}")]
13    InvalidDeclaration {
14        stable_key: String,
15        reason: &'static str,
16    },
17
18    /// The stable key namespace and memory ID range do not match.
19    #[error(
20        "memory stable key '{stable_key}' with id {id} violates namespace/range authority: {reason}"
21    )]
22    RangeAuthorityViolation {
23        /// Stable key being registered.
24        stable_key: String,
25        /// Stable-memory ID being registered.
26        id: u8,
27        /// Human-readable reason for the rejection.
28        reason: &'static str,
29    },
30
31    /// The persisted ABI ledger cannot be validated.
32    #[error("memory layout ledger is corrupt: {reason}")]
33    LedgerCorrupt {
34        /// Human-readable corruption reason.
35        reason: &'static str,
36    },
37}