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
12mod cell;
13mod heap;
14mod log;
15mod map;
16mod region;
17mod set;
18mod vector;
19
20#[cfg(all(test, not(target_arch = "wasm32")))]
21mod tests;
22
23/// Exact substrate interfaces for backing bounds and record codecs.
24/// Implementing `Memory` grants no allocation authority; constructors require
25/// committed `RuntimeMemory` leases.
26pub use crate::Memory;
27use crate::{DefaultMemoryImpl, RuntimeMemory, substrate};
28pub use substrate::{
29 Storable,
30 log::WriteError as LogWriteError,
31 storable::{self, Bound},
32};
33
34pub use cell::StableCell;
35pub use heap::StableMinHeap;
36pub use log::StableLog;
37pub use map::StableBTreeMap;
38pub use region::{BTreeMapRegion, RegionGrowError};
39pub use set::StableBTreeSet;
40pub use vector::StableVec;
41
42/// Upstream map iterator with governed memory.
43pub type MapIter<'a, K, V, M = DefaultMemoryImpl> =
44 substrate::btreemap::Iter<'a, K, V, RuntimeMemory<M>>;
45/// Upstream set iterator with governed memory.
46pub type SetIter<'a, K, M = DefaultMemoryImpl> = substrate::btreeset::Iter<'a, K, RuntimeMemory<M>>;
47/// Upstream log iterator with governed index and data memories.
48pub type LogIter<'a, T, M = DefaultMemoryImpl> =
49 substrate::log::Iter<'a, T, RuntimeMemory<M>, RuntimeMemory<M>>;