[][src]Trait ink_storage::traits::SpreadLayout

pub trait SpreadLayout {
    const FOOTPRINT: u64;
    const REQUIRES_DEEP_CLEAN_UP: bool;

    fn pull_spread(ptr: &mut KeyPtr) -> Self;
fn push_spread(&self, ptr: &mut KeyPtr);
fn clear_spread(&self, ptr: &mut KeyPtr); }

Types that can be stored to and loaded from the contract storage.

Associated Constants

const FOOTPRINT: u64

The footprint of the type.

This is the number of adjunctive cells the type requires in order to be stored in the contract storage with spread layout.

Examples

An instance of type i32 requires one storage cell so its footprint is

  1. An instance of type (i32, i32) requires 2 storage cells since a tuple or any other combined data structure always associates disjunct cells for its sub types. The same applies to arrays, e.g. [i32; 5] has a footprint of 5.

const REQUIRES_DEEP_CLEAN_UP: bool

Indicates whether a type requires deep clean-up of its state meaning that a clean-up routine has to decode an entity into an instance in order to eventually recurse upon its tear-down. This is not required for the majority of primitive data types such as i32, however types such as storage::Box that might want to forward the clean-up procedure to their inner T require a deep clean-up.

Note

The default is set to true in order to have correctness by default since no type invariants break if a deep clean-up is performed on a type that does not need it but performing a shallow clean-up for a type that requires a deep clean-up would break invariants. This is solely a setting to improve performance upon clean-up for some types.

Loading content...

Required methods

fn pull_spread(ptr: &mut KeyPtr) -> Self

Pulls an instance of Self from the contract storage.

The key pointer denotes the position where the instance is being pulled from within the contract storage

Note

This method of pulling is depth-first: Sub-types are pulled first and construct the super-type through this procedure.

fn push_spread(&self, ptr: &mut KeyPtr)

Pushes an instance of Self to the contract storage.

  • Tries to spread Self to as many storage cells as possible.
  • The key pointer denotes the position where the instance is being pushed to the contract storage.

Note

This method of pushing is depth-first: Sub-types are pushed before their parent or super type.

fn clear_spread(&self, ptr: &mut KeyPtr)

Clears an instance of Self from the contract storage.

  • Tries to clean Self from contract storage as if self was stored in it using spread layout.
  • The key pointer denotes the position where the instance is being cleared from the contract storage.

Note

This method of clearing is depth-first: Sub-types are cleared before their parent or super type.

Loading content...

Implementations on Foreign Types

impl<T> SpreadLayout for [T; 1] where
    T: SpreadLayout
[src]

impl<T> SpreadLayout for [T; 2] where
    T: SpreadLayout
[src]

impl<T> SpreadLayout for [T; 3] where
    T: SpreadLayout
[src]

impl<T> SpreadLayout for [T; 4] where
    T: SpreadLayout
[src]

impl<T> SpreadLayout for [T; 5] where
    T: SpreadLayout
[src]

impl<T> SpreadLayout for [T; 6] where
    T: SpreadLayout
[src]

impl<T> SpreadLayout for [T; 7] where
    T: SpreadLayout
[src]

impl<T> SpreadLayout for [T; 8] where
    T: SpreadLayout
[src]

impl<T> SpreadLayout for [T; 9] where
    T: SpreadLayout
[src]

impl<T> SpreadLayout for [T; 10] where
    T: SpreadLayout
[src]

impl<T> SpreadLayout for [T; 11] where
    T: SpreadLayout
[src]

impl<T> SpreadLayout for [T; 12] where
    T: SpreadLayout
[src]

impl<T> SpreadLayout for [T; 13] where
    T: SpreadLayout
[src]

impl<T> SpreadLayout for [T; 14] where
    T: SpreadLayout
[src]

impl<T> SpreadLayout for [T; 15] where
    T: SpreadLayout
[src]

impl<T> SpreadLayout for [T; 16] where
    T: SpreadLayout
[src]

impl<T> SpreadLayout for [T; 17] where
    T: SpreadLayout
[src]

impl<T> SpreadLayout for [T; 18] where
    T: SpreadLayout
[src]

impl<T> SpreadLayout for [T; 19] where
    T: SpreadLayout
[src]

impl<T> SpreadLayout for [T; 20] where
    T: SpreadLayout
[src]

impl<T> SpreadLayout for [T; 21] where
    T: SpreadLayout
[src]

impl<T> SpreadLayout for [T; 22] where
    T: SpreadLayout
[src]

impl<T> SpreadLayout for [T; 23] where
    T: SpreadLayout
[src]

impl<T> SpreadLayout for [T; 24] where
    T: SpreadLayout
[src]

impl<T> SpreadLayout for [T; 25] where
    T: SpreadLayout
[src]

impl<T> SpreadLayout for [T; 26] where
    T: SpreadLayout
[src]

impl<T> SpreadLayout for [T; 27] where
    T: SpreadLayout
[src]

impl<T> SpreadLayout for [T; 28] where
    T: SpreadLayout
[src]

impl<T> SpreadLayout for [T; 29] where
    T: SpreadLayout
[src]

impl<T> SpreadLayout for [T; 30] where
    T: SpreadLayout
[src]

impl<T> SpreadLayout for [T; 31] where
    T: SpreadLayout
[src]

impl<T> SpreadLayout for [T; 32] where
    T: SpreadLayout
[src]

impl<K, V> SpreadLayout for StdBTreeMap<K, V> where
    K: PackedLayout + Ord,
    V: PackedLayout
[src]

impl<T> SpreadLayout for StdBTreeSet<T> where
    T: PackedLayout + Ord
[src]

impl<T> SpreadLayout for StdBinaryHeap<T> where
    T: PackedLayout + Ord
[src]

impl<T> SpreadLayout for Vec<T> where
    T: PackedLayout
[src]

impl<T> SpreadLayout for StdLinkedList<T> where
    T: PackedLayout
[src]

impl<T> SpreadLayout for StdVecDeque<T> where
    T: PackedLayout
[src]

impl SpreadLayout for Key where
    Self: PackedLayout
[src]

impl SpreadLayout for Hash where
    Self: PackedLayout
[src]

impl SpreadLayout for AccountId where
    Self: PackedLayout
[src]

impl SpreadLayout for () where
    Self: PackedLayout
[src]

impl SpreadLayout for String where
    Self: PackedLayout
[src]

impl SpreadLayout for bool where
    Self: PackedLayout
[src]

impl SpreadLayout for u8 where
    Self: PackedLayout
[src]

impl SpreadLayout for u16 where
    Self: PackedLayout
[src]

impl SpreadLayout for u32 where
    Self: PackedLayout
[src]

impl SpreadLayout for u64 where
    Self: PackedLayout
[src]

impl SpreadLayout for u128 where
    Self: PackedLayout
[src]

impl SpreadLayout for i8 where
    Self: PackedLayout
[src]

impl SpreadLayout for i16 where
    Self: PackedLayout
[src]

impl SpreadLayout for i32 where
    Self: PackedLayout
[src]

impl SpreadLayout for i64 where
    Self: PackedLayout
[src]

impl SpreadLayout for i128 where
    Self: PackedLayout
[src]

impl<T> SpreadLayout for Option<T> where
    T: SpreadLayout
[src]

impl<T, E> SpreadLayout for Result<T, E> where
    T: SpreadLayout,
    E: SpreadLayout
[src]

impl<T> SpreadLayout for Box<T> where
    T: SpreadLayout
[src]

impl<A> SpreadLayout for (A,) where
    A: SpreadLayout
[src]

impl<A, B> SpreadLayout for (A, B) where
    A: SpreadLayout,
    B: SpreadLayout
[src]

impl<A, B, C> SpreadLayout for (A, B, C) where
    A: SpreadLayout,
    B: SpreadLayout,
    C: SpreadLayout
[src]

impl<A, B, C, D> SpreadLayout for (A, B, C, D) where
    A: SpreadLayout,
    B: SpreadLayout,
    C: SpreadLayout,
    D: SpreadLayout
[src]

impl<A, B, C, D, E> SpreadLayout for (A, B, C, D, E) where
    A: SpreadLayout,
    B: SpreadLayout,
    C: SpreadLayout,
    D: SpreadLayout,
    E: SpreadLayout
[src]

impl<A, B, C, D, E, F> SpreadLayout for (A, B, C, D, E, F) where
    A: SpreadLayout,
    B: SpreadLayout,
    C: SpreadLayout,
    D: SpreadLayout,
    E: SpreadLayout,
    F: SpreadLayout
[src]

impl<A, B, C, D, E, F, G> SpreadLayout for (A, B, C, D, E, F, G) where
    A: SpreadLayout,
    B: SpreadLayout,
    C: SpreadLayout,
    D: SpreadLayout,
    E: SpreadLayout,
    F: SpreadLayout,
    G: SpreadLayout
[src]

impl<A, B, C, D, E, F, G, H> SpreadLayout for (A, B, C, D, E, F, G, H) where
    A: SpreadLayout,
    B: SpreadLayout,
    C: SpreadLayout,
    D: SpreadLayout,
    E: SpreadLayout,
    F: SpreadLayout,
    G: SpreadLayout,
    H: SpreadLayout
[src]

impl<A, B, C, D, E, F, G, H, I> SpreadLayout for (A, B, C, D, E, F, G, H, I) where
    A: SpreadLayout,
    B: SpreadLayout,
    C: SpreadLayout,
    D: SpreadLayout,
    E: SpreadLayout,
    F: SpreadLayout,
    G: SpreadLayout,
    H: SpreadLayout,
    I: SpreadLayout
[src]

impl<A, B, C, D, E, F, G, H, I, J> SpreadLayout for (A, B, C, D, E, F, G, H, I, J) where
    A: SpreadLayout,
    B: SpreadLayout,
    C: SpreadLayout,
    D: SpreadLayout,
    E: SpreadLayout,
    F: SpreadLayout,
    G: SpreadLayout,
    H: SpreadLayout,
    I: SpreadLayout,
    J: SpreadLayout
[src]

Loading content...

Implementors

impl SpreadLayout for BitStash[src]

impl SpreadLayout for StorageBitvec[src]

impl<K, V, H> SpreadLayout for StorageHashMap<K, V, H> where
    K: Ord + Clone + PackedLayout,
    V: PackedLayout,
    H: CryptoHash,
    Key: From<<H as HashOutput>::Type>, 
[src]

impl<K, V, H> SpreadLayout for LazyHashMap<K, V, H> where
    K: Ord + Encode,
    V: PackedLayout,
    H: CryptoHash,
    Key: From<<H as HashOutput>::Type>, 
[src]

impl<T> SpreadLayout for Entry<T> where
    T: PackedLayout
[src]

impl<T> SpreadLayout for BinaryHeap<T> where
    T: PackedLayout + Ord
[src]

impl<T> SpreadLayout for Reverse<T> where
    T: PackedLayout + Ord
[src]

impl<T> SpreadLayout for StorageStash<T> where
    T: PackedLayout
[src]

impl<T> SpreadLayout for StorageVec<T> where
    T: PackedLayout
[src]

impl<T> SpreadLayout for Lazy<T> where
    T: SpreadLayout
[src]

impl<T> SpreadLayout for LazyCell<T> where
    T: SpreadLayout
[src]

impl<T> SpreadLayout for StorageBox<T> where
    T: SpreadLayout
[src]

impl<T> SpreadLayout for Memory<T> where
    T: Default
[src]

impl<T> SpreadLayout for Pack<T> where
    T: PackedLayout
[src]

impl<T, N> SpreadLayout for SmallVec<T, N> where
    T: PackedLayout,
    N: LazyArrayLength<T>, 
[src]

impl<T, N> SpreadLayout for LazyArray<T, N> where
    T: PackedLayout,
    N: LazyArrayLength<T>, 
[src]

impl<V> SpreadLayout for LazyIndexMap<V> where
    V: PackedLayout
[src]

Loading content...