Expand description
Custom derive for ink_storage traits.
This crate provides helpers to define your very own custom storage data
structures that work along the ink_storage data structures by implementing
SpreadLayout and PackedLayout traits.
See Spread vs. Packed for more details of these two root strategies.
§Examples
use ink_storage::traits::{SpreadLayout, push_spread_root};
use ink_primitives::Key;
// Enum
#[derive(SpreadLayout)]
enum Vote {
Yes,
No
}
// Strucut
#[derive(SpreadLayout)]
struct NamedFields {
a: u32,
b: [u32; 32],
};
// Created a custom structure and told which key to update.
push_spread_root(&NamedFields{ a: 123, b: [22; 32] }, &mut Key::from([0x42; 32]));Derive Macros§
- Packed
Layout - Derives
ink_storage’sPackedLayouttrait for the givenstructorenum. - Spread
Allocate - Derives
ink_storage’sSpreadAllocatetrait for the givenstruct. - Spread
Layout - Derives
ink_storage’sSpreadLayouttrait for the givenstructorenum. - Storage
Layout - Derives
ink_storage’sStorageLayouttrait for the givenstructorenum.