Derive Macro ink_storage_derive::SpreadLayout
source · [−]#[derive(SpreadLayout)]
Expand description
Derives ink_storage
’s SpreadLayout
trait for the given struct
or enum
.
Examples
use ink_primitives::Key;
use ink_storage::traits::{
SpreadLayout,
push_spread_root,
pull_spread_root,
};
#[derive(SpreadLayout)]
struct NamedFields {
a: u32,
b: [u32; 32],
}
let value = NamedFields {
a: 123,
b: [22; 32],
};
push_spread_root(&value, &mut Key::from([0x42; 32]));
let value2: NamedFields = pull_spread_root(&mut Key::from([0x42; 32]));
assert_eq!(value.a, value2.a);