cw_storage_plus/
lib.rs

1/*!
2After building `cosmwasm-storage`, we realized many of the design decisions were
3limiting us and producing a lot of needless boilerplate. The decision was made to leave
4those APIs stable for anyone wanting a very basic abstraction on the KV-store and to
5build a much more powerful and complex ORM layer that can provide powerful accessors
6using complex key types, which are transparently turned into bytes.
7
8This led to a number of breaking API changes in this package of the course of several
9releases as we updated this with lots of experience, user feedback, and deep dives to harness
10the full power of generics.
11
12For more information on this package, please check out the
13[README](https://github.com/CosmWasm/cw-plus/blob/main/packages/storage-plus/README.md).
14*/
15
16mod bound;
17mod de;
18mod deque;
19mod endian;
20mod helpers;
21mod indexed_map;
22mod indexed_snapshot;
23mod indexes;
24mod int_key;
25mod item;
26mod iter_helpers;
27mod keys;
28mod map;
29mod namespace;
30mod path;
31mod prefix;
32mod snapshot;
33
34#[cfg(feature = "iterator")]
35pub use bound::{Bound, Bounder, PrefixBound, RawBound};
36pub use de::KeyDeserialize;
37pub use deque::Deque;
38pub use deque::DequeIter;
39pub use endian::Endian;
40#[cfg(feature = "iterator")]
41pub use indexed_map::{IndexList, IndexedMap};
42#[cfg(feature = "iterator")]
43pub use indexed_snapshot::IndexedSnapshotMap;
44#[cfg(feature = "iterator")]
45pub use indexes::{Index, IndexPrefix, MultiIndex, UniqueIndex};
46pub use int_key::IntKey;
47pub use item::Item;
48pub use keys::{Key, Prefixer, PrimaryKey};
49pub use map::Map;
50pub use namespace::Namespace;
51pub use path::Path;
52#[cfg(feature = "iterator")]
53pub use prefix::{range_with_prefix, Prefix};
54#[cfg(feature = "iterator")]
55pub use snapshot::{SnapshotItem, SnapshotMap, Strategy};
56
57#[cfg(all(feature = "iterator", feature = "macro"))]
58/// Auto generate an `IndexList` impl for your indexes struct.
59///
60/// # Example
61///
62/// ```rust
63/// use cosmwasm_std::Addr;
64/// use cw_storage_plus::{MultiIndex, UniqueIndex, index_list};
65/// use serde::{Serialize, Deserialize};
66///
67/// #[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
68/// struct TestStruct {
69///     id: u64,
70///     id2: u32,
71///     addr: Addr,
72/// }
73///
74/// #[index_list(TestStruct)] // <- Add this line right here.
75/// struct TestIndexes<'a> {
76///     id: MultiIndex<'a, u32, TestStruct, u64>,
77///     addr: UniqueIndex<'a, Addr, TestStruct, ()>,
78/// }
79/// ```
80///
81pub use cw_storage_macro::index_list;
82
83#[cfg(all(feature = "iterator", feature = "macro"))]
84/// Auto generate the required impls to use a newtype as a key
85/// # Example
86///
87/// ```rust
88/// use cw_storage_plus::NewTypeKey;
89/// use serde::{Serialize, Deserialize};
90///
91/// #[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
92/// #[derive(NewTypeKey)] // <- Add this line right here.
93/// struct TestKey(u64);
94///
95/// // You can now use `TestKey` as a key in `Map`
96/// ```
97///
98pub use cw_storage_macro::NewTypeKey;