Skip to main content

ic_storage/
adapter.rs

1//! Governed collections with an explicit API.
2//!
3//! Storage owns every collection engine and its current format. Constructors
4//! enforce explicit creation and loading without exposing raw backing.
5//! Use distinct admitted allocations for owning collections. Region views retain
6//! a shared lease for disjoint application frames and reload roots per operation.
7//! Drop collections and all shared lease owners before reopening.
8//! Framing admission and explicit reservation can return typed errors. Collection
9//! engine and codec failures trap. Successful-call `Result` signatures remain;
10//! native callers must discard the runtime after a mutation panic.
11//! The allocation runtime enforces one live lease per allocation;
12//! hosts retain exclusive custody of the backing across runtimes.
13// Collection APIs require public documentation in addition to workspace Clippy.
14#![warn(clippy::all, clippy::pedantic, missing_docs)]
15use crate::DefaultMemoryImpl;
16pub use crate::storable::{Bound, CodecError, Storable};
17/// Storage-owned interfaces for backing bounds and record codecs.
18/// Implementing `Memory` grants no allocation authority; constructors require
19/// committed `RuntimeMemory` leases.
20pub use crate::{Memory, storable};
21
22#[cfg(all(test, not(target_arch = "wasm32")))]
23mod tests;
24
25mod error;
26pub use error::CollectionError;
27mod bridge;
28mod iteration;
29
30mod region;
31pub use region::{BTreeMapRegion, RegionGrowError};
32
33mod map;
34pub use map::StableBTreeMap;
35mod set;
36pub use set::StableBTreeSet;
37mod cell;
38pub use cell::StableCell;
39mod vector;
40pub use vector::StableVec;
41
42/// Ordered map iterator retaining the collection borrow.
43pub use iteration::{MapEntry, MapIter};
44/// Ordered set iterator retaining the collection borrow.
45pub type SetIter<'a, K, M = DefaultMemoryImpl> = set::SetIter<'a, K, M>;