Crate ic_stable_memory

source ·
Expand description

This crate provides a number of “stable” data structures - collections that use canister’s stable memory for storage, as well as other primitives that allow storing all data of your canister in stable memory. This crate also provides the SCertifiedBTreeMap - a Merkle-tree based collection that can be used to include custom data into canister’s certified state tree.

This documentation only covers API and some implementation details. For more useful info and tutorials, please visit project’s Github page.

Features

  1. Stable data structures release their memory automatically, following Rust’s ownership rules.
  2. Stable data structures also obey and enforce Rust’s borrowing and lifetime rules.
  3. Each data structure is aware of the limited nature of memory in IC and allows programmatic reaction for situations when your canister is out of stable memory.
  4. Each data structure’s performance is reasonably close to its std’s analog.
  5. Supported stable data structures: box, vec, log, hash-map, hash-set, btree-map, btree-set, certified-map.
  6. In addition to these data structures, this crate provides you with a fully featured toolset to build your own data structure, if you need something more domain-specific.

Re-exports

Modules

  • All collections provided by this crate
  • Traits and algorithms for internal data encoding Traits and encoding algorithms used by this crate.
  • Stable memory allocator and related structs Various functions and data structures to organize and work with raw stable memory.
  • Stable memory smart-pointers Smart-pointers and StableType trait
  • Various utilities: certification, stable memory API wrapper etc. Various utilities used by this crate

Macros

Traits

  • Trait that is used to hash a leaf value of a [HashTree].
  • Trait that is used to serialize labels of a [HashTree] into bytes.

Functions