[][src]Struct ink_storage::Box

pub struct Box<T> where
    T: SpreadLayout
{ /* fields omitted */ }

A dynamically allocated storage entity.

Users can use this in order to make certain SpreadLayout storage entities used in contexts that require a PackedLayout storage entity by simply packing the storage entity witihn a storage::Box.

Dynamic allocations caused by the creation of storage::Box instances do have some limited overhead:

  • The dynamic allocation itself has to be provided by some dynamic storage allocator that needs to be invoked.
  • Each dynamic storage allocation implies roughly 1.12 bits of overhead.
  • Upon ever first dereferencing of a storage::Box instance a cryptographic hash routine is run in order to compute the underlying storage key.

Use this abstraction with caution due to the aforementioned performance implications.

Implementations

impl<T> Box<T> where
    T: SpreadLayout
[src]

pub fn new(value: T) -> Self[src]

Creates a new boxed entity.

impl<T> Box<T> where
    T: SpreadLayout
[src]

#[must_use]pub fn get(boxed: &Self) -> &T[src]

Returns a shared reference to the boxed value.

Note

This loads the value from the pointed to contract storage if this did not happen before.

Panics

If loading from contract storage failed.

#[must_use]pub fn get_mut(boxed: &mut Self) -> &mut T[src]

Returns an exclusive reference to the boxed value.

Note

This loads the value from the pointed to contract storage if this did not happen before.

Panics

If loading from contract storage failed.

Trait Implementations

impl<T> AsMut<T> for StorageBox<T> where
    T: SpreadLayout
[src]

impl<T> AsRef<T> for StorageBox<T> where
    T: SpreadLayout
[src]

impl<T> Borrow<T> for StorageBox<T> where
    T: SpreadLayout
[src]

impl<T> BorrowMut<T> for StorageBox<T> where
    T: SpreadLayout
[src]

impl<T: Debug> Debug for Box<T> where
    T: SpreadLayout
[src]

impl<T> Decode for StorageBox<T> where
    T: SpreadLayout
[src]

impl<T> Deref for StorageBox<T> where
    T: SpreadLayout
[src]

type Target = T

The resulting type after dereferencing.

impl<T> DerefMut for StorageBox<T> where
    T: SpreadLayout
[src]

impl<T> Display for StorageBox<T> where
    T: Display + SpreadLayout
[src]

impl<T> Drop for StorageBox<T> where
    T: SpreadLayout
[src]

impl<T> Encode for StorageBox<T> where
    T: SpreadLayout
[src]

impl<T> Eq for StorageBox<T> where
    T: Eq + SpreadLayout
[src]

impl<T> Hash for StorageBox<T> where
    T: Hash + SpreadLayout
[src]

impl<T> Ord for StorageBox<T> where
    T: Ord + SpreadLayout
[src]

impl<T> PackedLayout for StorageBox<T> where
    T: SpreadLayout
[src]

impl<T> PartialEq<Box<T>> for StorageBox<T> where
    T: PartialEq + SpreadLayout
[src]

impl<T> PartialOrd<Box<T>> for StorageBox<T> where
    T: PartialOrd + SpreadLayout
[src]

impl<T> SpreadLayout for StorageBox<T> where
    T: SpreadLayout
[src]

impl<T> StorageLayout for StorageBox<T> where
    T: SpreadLayout
[src]

Auto Trait Implementations

impl<T> !RefUnwindSafe for Box<T>

impl<T> Send for Box<T> where
    T: Send

impl<T> !Sync for Box<T>

impl<T> Unpin for Box<T> where
    T: Unpin

impl<T> UnwindSafe for Box<T> where
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T, U> AsByteSlice<T> for U where
    T: ToByteSlice,
    U: AsRef<[T]> + ?Sized

impl<T, U> AsMutByteSlice<T> for U where
    T: ToMutByteSlice,
    U: AsMut<[T]> + ?Sized

impl<U> AsMutSliceOf for U where
    U: AsMut<[u8]> + ?Sized

impl<U> AsSliceOf for U where
    U: AsRef<[u8]> + ?Sized

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<S> Codec for S where
    S: Encode + Decode
[src]

impl<T, X> Decode for X where
    T: Decode + Into<X>,
    X: WrapperTypeDecode<Wrapped = T>, 
[src]

impl<T> DecodeAll for T where
    T: Decode
[src]

impl<T> DecodeLimit for T where
    T: Decode
[src]

impl<T, X> Encode for X where
    T: Encode + ?Sized,
    X: WrapperTypeEncode<Target = T>, 
[src]

impl<'_, '_, T> EncodeLike<&'_ &'_ T> for T where
    T: Encode
[src]

impl<'_, T> EncodeLike<&'_ T> for T where
    T: Encode
[src]

impl<'_, T> EncodeLike<&'_ mut T> for T where
    T: Encode
[src]

impl<T> EncodeLike<Arc<T>> for T where
    T: Encode
[src]

impl<T> EncodeLike<Box<T>> for T where
    T: Encode
[src]

impl<T> EncodeLike<Rc<T>> for T where
    T: Encode
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> KeyedVec for T where
    T: Codec
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,