icydb-core 0.261.0

IcyDB — A schema-first typed query engine and persistence runtime for Internet Computer canisters
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
//! Module: memory
//! Responsibility: resolve physical IDs from committed logical allocation authority.
//! Does not own: allocation, caching, placement, or schema authority.
//! Boundary: runtime identity consumers to the shared ic-memory capability.

use ic_memory::{RuntimeOpenError, StableKey, committed_allocations};

pub(crate) fn committed_memory_id(key: &str) -> Result<u8, RuntimeOpenError> {
    let allocations = committed_allocations()?;
    let key = StableKey::parse(key)?;
    let slot = allocations
        .slot_for(&key)
        .ok_or_else(|| RuntimeOpenError::StableKeyNotCommitted(key.to_string()))?;
    slot.memory_manager_id().map_err(Into::into)
}