Struct near_contract_tools::slot::Slot
source · Expand description
A storage slot, composed of a storage location (key) and a data type
Fields§
§key: Vec<u8>
The storage key this slot controls
Implementations§
source§impl Slot<()>
impl Slot<()>
sourcepub fn root<K: IntoStorageKey>(key: K) -> Self
pub fn root<K: IntoStorageKey>(key: K) -> Self
A placeholder slot. Useful for creating namespaced fields.
source§impl<T> Slot<T>
impl<T> Slot<T>
sourcepub fn new(key: impl IntoStorageKey) -> Self
pub fn new(key: impl IntoStorageKey) -> Self
Creates a new Slot
that controls the given storage key
sourcepub fn ns(&self, key: impl IntoStorageKey) -> Slot<()>
pub fn ns(&self, key: impl IntoStorageKey) -> Slot<()>
Creates a new Slot
that controls the given key namespaced (prefixed)
by the parent key, to be used as a namespace for another subfield.
sourcepub fn field<U>(&self, key: impl IntoStorageKey) -> Slot<U>
pub fn field<U>(&self, key: impl IntoStorageKey) -> Slot<U>
Creates a new Slot
that controls the given key namespaced (prefixed)
by the parent key.
sourcepub fn transmute<U>(&self) -> Slot<U>
pub fn transmute<U>(&self) -> Slot<U>
Creates a Slot
that tries to parse a different data type from the same
storage slot.
Warning
If the data in the slot is not parsable into the new type, methods like
Slot::read
and Slot::take
will panic.
sourcepub fn write_raw(&mut self, value: &[u8]) -> bool
pub fn write_raw(&mut self, value: &[u8]) -> bool
Write raw bytes into the storage slot. No type checking.
sourcepub fn read_raw(&self) -> Option<Vec<u8>>
pub fn read_raw(&self) -> Option<Vec<u8>>
Read raw bytes from the slot. No type checking or parsing.