pub struct Slot<T> {
    pub key: Vec<u8>,
    /* private fields */
}
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§

A placeholder slot. Useful for creating namespaced fields.

Creates a new Slot that controls the given storage key

Creates a new Slot that controls the given key namespaced (prefixed) by the parent key, to be used as a namespace for another subfield.

Creates a new Slot that controls the given key namespaced (prefixed) by the parent key.

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.

Write raw bytes into the storage slot. No type checking.

Read raw bytes from the slot. No type checking or parsing.

Returns true if this slot’s key is currently present in the smart contract storage, false otherwise

Removes the managed key from storage

Writes a value to the managed storage slot

If the given value is Some(T), writes T to storage. Otherwise, removes the key from storage.

Use of this method makes the slot function similarly to [near_sdk::collections::LazyOption].

Reads a value from storage, if present.

Removes a value from storage and returns it if present.

Writes a value to storage and returns the evicted value, if present.

Trait Implementations§

Deserializes this instance from a given slice of bytes. Updates the buffer to point at the remaining bytes. Read more
Deserialize this instance from a slice of bytes.
Serialize this instance into a vector of bytes.
Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Consumes self and returns Vec<u8> bytes which are used as a storage key.
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.