pub struct Slots(/* private fields */);
Expand description
Collection of slots, primarily for execution environment
Implementations§
Source§impl Slots
impl Slots
Sourcepub fn new<I>(slots: I) -> Selfwhere
I: IntoIterator<Item = Slot>,
pub fn new<I>(slots: I) -> Selfwhere
I: IntoIterator<Item = Slot>,
Create a new instance from a hashmap containing existing slots.
Only slots that are present in the input can be modified. The only exception is slots for
owners created during runtime and initialized with Self::add_new_contract()
.
“Empty” slots must still have a value in the form of an empty [SharedAlignedBuffer
].
Sourcepub fn new_nested_rw(&mut self) -> NestedSlots<'_>
pub fn new_nested_rw(&mut self) -> NestedSlots<'_>
Create a new nested read-write slots instance.
Nested instance will integrate its changes into the parent slot when dropped (or changes can
be reset with NestedSlots::reset()
).
Sourcepub fn new_nested_ro(&self) -> NestedSlots<'_>
pub fn new_nested_ro(&self) -> NestedSlots<'_>
Create a new nested read-only slots instance
Sourcepub fn add_new_contract(&mut self, owner: Address) -> bool
pub fn add_new_contract(&mut self, owner: Address) -> bool
Add a new contract that didn’t exist before.
In contrast to contracts in Self::new()
, this contract will be allowed to have any slots
related to it being modified.
Returns false
if a contract already exits in a map, which is also considered as an access
violation.
Sourcepub fn iter(
&self,
) -> impl ExactSizeIterator<Item = (&SlotKey, &SharedAlignedBuffer)> + '_
pub fn iter( &self, ) -> impl ExactSizeIterator<Item = (&SlotKey, &SharedAlignedBuffer)> + '_
Iterate over all slots in the collection
Sourcepub fn iter_modified(
&self,
) -> impl Iterator<Item = (&SlotKey, &SharedAlignedBuffer)> + '_
pub fn iter_modified( &self, ) -> impl Iterator<Item = (&SlotKey, &SharedAlignedBuffer)> + '_
Iterate over modified slots in the collection
Sourcepub fn into_slots(
self,
) -> impl ExactSizeIterator<Item = (SlotKey, SharedAlignedBuffer)>
pub fn into_slots( self, ) -> impl ExactSizeIterator<Item = (SlotKey, SharedAlignedBuffer)>
Extract all slots in the collection