ic_storage/adapter/mod.rs
1//! Supported upstream collections with governed memory and an explicit API.
2//!
3//! Constructors preserve upstream initialization, panic and persisted-format
4//! contracts. These wrappers expose neither raw memory nor unrestricted
5//! upstream collections.
6//! Use distinct admitted allocations for owning collections. Region views retain
7//! a shared lease for disjoint application frames and reload roots per operation.
8//! Drop collections and all shared lease owners before reopening.
9//! Storage enforces one live lease per allocation within each runtime;
10//! hosts retain exclusive custody of the backing across runtimes.
11/// Exact substrate interfaces for backing bounds and record codecs.
12/// Implementing `Memory` grants no allocation authority; constructors require
13/// committed `RuntimeMemory` leases.
14pub use crate::Memory;
15use crate::RuntimeMemory;
16use crate::{DefaultMemoryImpl, substrate};
17pub use substrate::{Storable, storable, storable::Bound};
18
19#[cfg(all(test, not(target_arch = "wasm32")))]
20mod tests;
21
22mod region;
23pub use region::{BTreeMapRegion, RegionGrowError};
24
25mod map;
26pub use map::StableBTreeMap;
27mod set;
28pub use set::StableBTreeSet;
29mod cell;
30pub use cell::StableCell;
31mod vector;
32pub use vector::StableVec;
33mod heap;
34pub use heap::StableMinHeap;
35mod log;
36pub use log::StableLog;
37
38/// Upstream map iterator with governed memory.
39pub type MapIter<'a, K, V, M = DefaultMemoryImpl> =
40 substrate::btreemap::Iter<'a, K, V, RuntimeMemory<M>>;
41/// Upstream set iterator with governed memory.
42pub type SetIter<'a, K, M = DefaultMemoryImpl> = substrate::btreeset::Iter<'a, K, RuntimeMemory<M>>;
43/// Upstream log iterator with governed index and data memories.
44pub type LogIter<'a, T, M = DefaultMemoryImpl> =
45 substrate::log::Iter<'a, T, RuntimeMemory<M>, RuntimeMemory<M>>;
46
47pub use substrate::log::WriteError as LogWriteError;