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;
# ink_env::test::run_test::<ink_env::DefaultEnvironment, _>(|_| {
// 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]));
# Ok(())
# });