Expand description
After building cosmwasm-storage, we realized many of the design decisions were
limiting us and producing a lot of needless boilerplate. The decision was made to leave
those APIs stable for anyone wanting a very basic abstraction on the KV-store and to
build a much more powerful and complex ORM layer that can provide powerful accessors
using complex key types, which are transparently turned into bytes.
This led to a number of breaking API changes in this package of the course of several releases as we updated this with lots of experience, user feedback, and deep dives to harness the full power of generics.
For more information on this package, please check out the README.
Structs§
- Deque
- A deque stores multiple items at the given key. It provides efficient FIFO and LIFO access, as well as direct index access.
- Deque
Iter - Index
Prefix - Indexed
Map IndexedMapworks like aMapbut has a secondary index- Indexed
Snapshot Map IndexedSnapshotMapworks like aSnapshotMapbut has a secondary index- Item
- Item stores one typed item at the given key. This is an analog of Singleton. It functions the same way as Path does but doesn’t use a Vec and thus has a const fn constructor.
- Map
- Multi
Index - MultiIndex stores (namespace, index_name, idx_value, pk) -> b“pk_len“. Allows many values per index, and references pk. The associated primary key value is stored in the main (pk_namespace) map, which stores (namespace, pk_namespace, pk) -> value.
- Namespace
- The namespace of a storage container. Meant to be constructed from “stringy” types.
- Path
- Prefix
- Snapshot
Item - Item that maintains a snapshot of one or more checkpoints. We can query historical data as well as current state. What data is snapshotted depends on the Strategy.
- Snapshot
Map - Map that maintains a snapshots of one or more checkpoints. We can query historical data as well as current state. What data is snapshotted depends on the Strategy.
- Unique
Index - UniqueIndex stores (namespace, index_name, idx_value) -> {key, value} Allows one value per index (i.e. unique) and copies pk and data The PK type defines the type of Primary Key deserialization.
Enums§
- Bound
Boundis used to define the two ends of a range.Nonemeans that we don’t limit that side of the range at all.Inclusivemeans we use the given value as a limit and include anything at that exact key.Exclusivemeans we use the given value as a limit and exclude anything at that exact key.- Key
- Prefix
Bound - RawBound
RawBoundis used to define the two ends of a range, more explicit thanOption<u8>.Nonemeans that we don’t limit that side of the range at all.Inclusivemeans we use the given bytes as a limit and include anything at that exact key.Exclusivemeans we use the given bytes as a limit and exclude anything at that exact key. SeeBoundfor a type safe way to build these bounds.- Strategy
Traits§
- Bounder
- Endian
- Index
- Index
List - IntKey
- Our int keys are simply the big-endian representation bytes for unsigned ints, but “sign-flipped” (xored msb) big-endian bytes for signed ints.
- KeyDeserialize
- Prefixer
- Primary
Key PrimaryKeyneeds to be implemented for types that want to be aMap(orMap-like) key, or part of a key.
Functions§
- range_
with_ prefix - Returns an iterator through all records in storage with the given prefix and within the given bounds, yielding the key without prefix and value.
Attribute Macros§
- index_
list - Auto generate an
IndexListimpl for your indexes struct.
Derive Macros§
- NewType
Key - Auto generate the required impls to use a newtype as a key