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//! Collection IO and codecs return typed errors for validation and capacity
9//! refusal. Backing panics/traps remain host failures; native writes are not atomic.
10//! Map and set iterators yield `Result` entries and stop after an iteration error.
11//! The allocation runtime enforces one live lease per allocation;
12//! hosts retain exclusive custody of the backing across runtimes.
13// Preserve the collection layer's pre-consolidation lint policy.
14#![allow(clippy::nursery)]
15#![warn(clippy::all, clippy::pedantic, missing_docs)]
16use crate::DefaultMemoryImpl;
17use crate::RuntimeMemory;
18pub use crate::storable::{Bound, CodecError, Storable};
19/// Storage-owned interfaces for backing bounds and record codecs.
20/// Implementing `Memory` grants no allocation authority; constructors require
21/// committed `RuntimeMemory` leases.
22pub use crate::{Memory, storable};
23
24#[cfg(all(test, not(target_arch = "wasm32")))]
25mod improvements_tests;
26#[cfg(all(test, not(target_arch = "wasm32")))]
27mod owned_tests;
28#[cfg(all(test, not(target_arch = "wasm32")))]
29mod tests;
30
31mod error;
32mod record;
33pub use error::CollectionError;
34mod tree;
35
36mod region;
37pub use region::{BTreeMapRegion, RegionGrowError};
38
39mod map;
40pub use map::StableBTreeMap;
41mod set;
42pub use set::StableBTreeSet;
43mod cell;
44pub use cell::StableCell;
45mod vector;
46pub use vector::StableVec;
47
48/// Ordered map iterator retaining the collection borrow.
49pub type MapIter<'a, K, V, M = DefaultMemoryImpl> = tree::TreeIter<'a, K, V, RuntimeMemory<M>>;
50pub use tree::MapEntry;
51/// Ordered set iterator retaining the collection borrow.
52pub type SetIter<'a, K, M = DefaultMemoryImpl> = set::SetIter<'a, K, M>;