Struct sway_types::state::StateIndex
source · pub struct StateIndex(_);
Expand description
Represents the position in a storage statement that a field was declared.
For example, in the following storage declaration, foo
has StateIndex 0 and bar
has
StateIndex 1.
The actual [StorageSlot] is calculated as the sha256 hash of the domain separator [sway_utils::constants::STORAGE_DOMAIN_SEPARATOR] concatenated with the index.
Here, foo
’s [StorageSlot] is sha256(format!("{}{}", STORAGE_DOMAIN_SEPARATOR, 0))
or
F383B0CE51358BE57DAA3B725FE44ACDB2D880604E367199080B4379C41BB6ED
.
bar
’s [StorageSlot] is sha256(format!("{}{}", STORAGE_DOMAIN_SEPARATOR, 1))
or
DE9090CB50E71C2588C773487D1DA7066D0C719849A7E58DC8B6397A25C567C0
.
Implementations§
Trait Implementations§
source§impl Clone for StateIndex
impl Clone for StateIndex
source§fn clone(&self) -> StateIndex
fn clone(&self) -> StateIndex
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for StateIndex
impl Debug for StateIndex
source§impl PartialEq<StateIndex> for StateIndex
impl PartialEq<StateIndex> for StateIndex
source§fn eq(&self, other: &StateIndex) -> bool
fn eq(&self, other: &StateIndex) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.