Crates.io | tw-storage-macros |
lib.rs | tw-storage-macros |
version | 0.1.2 |
source | src |
created_at | 2022-05-20 14:57:49.897009 |
updated_at | 2022-05-20 14:57:49.897009 |
description | Procedural macros helper for interacting with `cw-storage-plus` and `cosmwasm-storage` |
homepage | |
repository | https://github.com/TwilightCouncil/twilight-standard |
max_upload_size | |
id | 590328 |
size | 22,628 |
Procedural macros helper for interacting with cw-storage-plus
and cosmwasm-storage
.
Auto generate IndexList
impl for your indexes struct.
index_list_impl(T)
will generate impl IndexList<T>
for struct T
below the macro's call.
IndexList
, Index
imports from cw-storage-plus
are also required.
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
struct TestStruct {
id: u64,
id2: u32,
addr: Addr,
}
#[index_list_impl(TestStruct)] // <- Add this line right here,.
struct TestIndexes<'a> {
id: MultiIndex<'a, (U32Key, Vec<u8>), TestStruct>,
addr: UniqueIndex<'a, Addr, TestStruct>,
}
Auto generate PrimaryKey
and Prefixer
impl for owned and reference variants, as_bytes
and from_slice
impl.
StorageKey
will generate
impl PrimaryKey<'_> for T
impl<'a> PrimaryKey<'a> for &'a T
impl Prefixer<'_> for T
impl<'a> Prefixer<'a> for &'a T
pub fn as_bytes(&self) -> &[u8]
pub fn from_slice(b: &[u8]) -> T
for enum T
below the macro's call.
PrimaryKey
, Prefixer
imports from cw-storage-plus
are also required.
#[derive(Clone, Copy, StorageKey)] // <- Add the derive macro here.
enum TestEnum {
G,
F,
}
```r