This repository provides stable data structures for the Internet Computer that persist across canister upgrades. These structures do not require pre_upgrade or post_upgrade hooks.
The main modules include:
BTreeMap— key-value storageBTreeSet— setsVec— growable arraysCell— single valuesLog— append-only dataMinHeap— priority queuesMemoryManager— coordinates multiple structures in stable memory
Key entry points for understanding and using this library:
README.md— quick start and basic usage patternsdocs/— mdBook with concepts, design principles, and tutorialssrc/lib.rs— crate-level documentation and public API overviewexamples/— production-ready examples showing real-world usagesrc/btreemap.rs,src/btreeset.rs,src/vec.rs, etc. — individual module documentationCargo.toml— version and dependency information
Code defines behavior. Documentation must accurately reflect the current implementation. When making changes:
- update documentation in the same PR as code changes
- ensure examples compile and run correctly
- keep API documentation synchronized with function signatures
- update book chapters when changing core concepts
Follow this sequence to understand the library:
README.mdfor overview and quick examplesdocs/src/introduction/for concepts and design principlesdocs/src/concepts/forMemorytrait andMemoryManagerdetails- module documentation (
src/*.rs) for specific data structure APIs examples/for production usage patterns- code comments for implementation details
When changing public APIs:
- describe scope of changes in PR description
- update module-level documentation for affected types
- add or update runnable examples demonstrating the change
- update book chapters if concepts change
- verify
cargo docbuilds without warnings - verify
mdbook buildsucceeds - test examples compile and run
Every public type and module must have:
- short overview explaining purpose and use cases
- basic usage example that compiles
- links to related documentation or examples
- clear parameter and return value descriptions
- complexity information where relevant
- error conditions and panics documented