storage_slot - [devnet]
use 0x1::features;use 0x1::object;use 0x1::signer;Constants
Storage slot natives are not enabled.
const ESTORAGE_SLOT_NATIVES_NOT_ENABLED: u64 = 1;Resource under storage slot not found, this should never happen. Emitted by native functions.
const ESTORAGE_SLOT_NOT_FOUND: u64 = 2;Structs
StorageSlot
struct StorageSlot<T> has storeFields
-
addr: address
Resources
StorageSlotResource
struct StorageSlotResource<T> has keyFields
-
val: T
Functions
new
public fun new<T: store>(value: T): storage_slot::StorageSlot<T>Implementation
public fun new<T: store>(value: T): StorageSlot<T> { let unique_signer = object::create_unique_onchain_signer().generate_signer_for_extending(); move_to(&unique_signer, StorageSlotResource { val: value }); StorageSlot { addr: unique_signer.address_of() }}borrow_storage_slot_resource
fun borrow_storage_slot_resource<T: store, BR>(self: &storage_slot::StorageSlot<T>): &BRImplementation
native fun borrow_storage_slot_resource<T: store, BR>(self: &StorageSlot<T>): &BR;borrow_storage_slot_resource_mut
fun borrow_storage_slot_resource_mut<T: store, BR>(self: &mut storage_slot::StorageSlot<T>): &mut BRImplementation
native fun borrow_storage_slot_resource_mut<T: store, BR>(self: &mut StorageSlot<T>): &mut BR;borrow
public fun borrow<T: store>(self: &storage_slot::StorageSlot<T>): &TImplementation
public fun borrow<T: store>(self: &StorageSlot<T>): &T { assert!(std::features::is_storage_slot_natives_enabled(), ESTORAGE_SLOT_NATIVES_NOT_ENABLED); &self.borrow_storage_slot_resource<T, StorageSlotResource<T>>().val}borrow_mut
public fun borrow_mut<T: store>(self: &mut storage_slot::StorageSlot<T>): &mut TImplementation
public fun borrow_mut<T: store>(self: &mut StorageSlot<T>): &mut T { assert!(std::features::is_storage_slot_natives_enabled(), ESTORAGE_SLOT_NATIVES_NOT_ENABLED); &mut self.borrow_storage_slot_resource_mut<T, StorageSlotResource<T>>().val}copy_storage_slot
public fun copy_storage_slot<T: copy, store>(self: &storage_slot::StorageSlot<T>): storage_slot::StorageSlot<T>Implementation
public fun copy_storage_slot<T: store + copy>(self: &StorageSlot<T>): StorageSlot<T> { new(*self.borrow())}destroy
public fun destroy<T: store>(self: storage_slot::StorageSlot<T>): TImplementation
public fun destroy<T: store>(self: StorageSlot<T>): T { let StorageSlot { addr } = self; let StorageSlotResource { val } = move_from<StorageSlotResource<T>>(addr); val}Specification
pragma verify = false;new
public fun new<T: store>(value: T): storage_slot::StorageSlot<T>pragma verify = false;borrow
public fun borrow<T: store>(self: &storage_slot::StorageSlot<T>): &Tpragma opaque;pragma verify = false;aborts_if [abstract] false;borrow_mut
public fun borrow_mut<T: store>(self: &mut storage_slot::StorageSlot<T>): &mut Tpragma opaque;pragma verify = false;aborts_if [abstract] false;copy_storage_slot
public fun copy_storage_slot<T: copy, store>(self: &storage_slot::StorageSlot<T>): storage_slot::StorageSlot<T>pragma verify = false;destroy
public fun destroy<T: store>(self: storage_slot::StorageSlot<T>): Tpragma verify = false;