Struct ink_storage::Box [−][src]
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]
T: SpreadLayout,
impl<T> Box<T> where
T: SpreadLayout,
[src]
T: SpreadLayout,
#[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]
Trait Implementations
impl<T> AsMut<T> for StorageBox<T> where
T: SpreadLayout,
[src]
T: SpreadLayout,
impl<T> AsRef<T> for StorageBox<T> where
T: SpreadLayout,
[src]
T: SpreadLayout,
impl<T> Borrow<T> for StorageBox<T> where
T: SpreadLayout,
[src]
T: SpreadLayout,
impl<T> BorrowMut<T> for StorageBox<T> where
T: SpreadLayout,
[src]
T: SpreadLayout,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T: Debug> Debug for Box<T> where
T: SpreadLayout,
[src]
T: SpreadLayout,
impl<T> Decode for StorageBox<T> where
T: SpreadLayout,
[src]
T: SpreadLayout,
fn decode<I: Input>(value: &mut I) -> Result<Self, Error>
[src]
pub fn skip<I>(input: &mut I) -> Result<(), Error> where
I: Input,
[src]
I: Input,
pub fn encoded_fixed_size() -> Option<usize>
[src]
impl<T> Deref for StorageBox<T> where
T: SpreadLayout,
[src]
T: SpreadLayout,
impl<T> DerefMut for StorageBox<T> where
T: SpreadLayout,
[src]
T: SpreadLayout,
impl<T> Display for StorageBox<T> where
T: Display + SpreadLayout,
[src]
T: Display + SpreadLayout,
impl<T> Drop for StorageBox<T> where
T: SpreadLayout,
[src]
T: SpreadLayout,
impl<T> Encode for StorageBox<T> where
T: SpreadLayout,
[src]
T: SpreadLayout,
fn size_hint(&self) -> usize
[src]
fn encode_to<O: Output + ?Sized>(&self, dest: &mut O)
[src]
fn encode(&self) -> Vec<u8>
[src]
fn using_encoded<R, F: FnOnce(&[u8]) -> R>(&self, f: F) -> R
[src]
pub fn encoded_size(&self) -> usize
[src]
impl<T> Eq for StorageBox<T> where
T: Eq + SpreadLayout,
[src]
T: Eq + SpreadLayout,
impl<T> Hash for StorageBox<T> where
T: Hash + SpreadLayout,
[src]
T: Hash + SpreadLayout,
fn hash<H: Hasher>(&self, state: &mut H)
[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<T> Ord for StorageBox<T> where
T: Ord + SpreadLayout,
[src]
T: Ord + SpreadLayout,
fn cmp(&self, other: &Self) -> Ordering
[src]
#[must_use]pub fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]
impl<T> PackedLayout for StorageBox<T> where
T: SpreadLayout,
[src]
T: SpreadLayout,
fn pull_packed(&mut self, _at: &Key)
[src]
fn push_packed(&self, _at: &Key)
[src]
fn clear_packed(&self, _at: &Key)
[src]
impl<T> PartialEq<Box<T>> for StorageBox<T> where
T: PartialEq + SpreadLayout,
[src]
T: PartialEq + SpreadLayout,
impl<T> PartialOrd<Box<T>> for StorageBox<T> where
T: PartialOrd + SpreadLayout,
[src]
T: PartialOrd + SpreadLayout,
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
fn lt(&self, other: &Self) -> bool
[src]
fn le(&self, other: &Self) -> bool
[src]
fn ge(&self, other: &Self) -> bool
[src]
fn gt(&self, other: &Self) -> bool
[src]
impl<T> SpreadLayout for StorageBox<T> where
T: SpreadLayout,
[src]
T: SpreadLayout,
const FOOTPRINT: u64
[src]
fn pull_spread(ptr: &mut KeyPtr) -> Self
[src]
fn push_spread(&self, ptr: &mut KeyPtr)
[src]
fn clear_spread(&self, ptr: &mut KeyPtr)
[src]
const REQUIRES_DEEP_CLEAN_UP: bool
[src]
impl<T> StorageLayout for StorageBox<T> where
T: SpreadLayout,
[src]
T: SpreadLayout,
impl<T> TypeInfo for StorageBox<T> where
T: SpreadLayout + 'static,
[src]
T: SpreadLayout + 'static,
Auto Trait Implementations
impl<T> !RefUnwindSafe for Box<T>
impl<T> Send for Box<T> where
T: Send,
T: Send,
impl<T> !Sync for Box<T>
impl<T> Unpin for Box<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Box<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T, U> AsByteSlice<T> for U where
T: ToByteSlice,
U: AsRef<[T]> + ?Sized,
T: ToByteSlice,
U: AsRef<[T]> + ?Sized,
pub fn as_byte_slice(&self) -> &[u8]
impl<T, U> AsMutByteSlice<T> for U where
T: ToMutByteSlice,
U: AsMut<[T]> + ?Sized,
T: ToMutByteSlice,
U: AsMut<[T]> + ?Sized,
pub fn as_mut_byte_slice(&mut self) -> &mut [u8]
impl<U> AsMutSliceOf for U where
U: AsMut<[u8]> + ?Sized,
U: AsMut<[u8]> + ?Sized,
pub fn as_mut_slice_of<T>(&mut self) -> Result<&mut [T], Error> where
T: FromByteSlice,
T: FromByteSlice,
impl<U> AsSliceOf for U where
U: AsRef<[u8]> + ?Sized,
U: AsRef<[u8]> + ?Sized,
pub fn as_slice_of<T>(&self) -> Result<&[T], Error> where
T: FromByteSlice,
T: FromByteSlice,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<S> Codec for S where
S: Encode + Decode,
[src]
S: Encode + Decode,
impl<C, T> CoordTranslate for T where
C: CoordTranslate,
T: Deref<Target = C>,
C: CoordTranslate,
T: Deref<Target = C>,
type From = <C as CoordTranslate>::From
pub fn translate(&self, from: &<T as CoordTranslate>::From) -> (i32, i32)
impl<T> DecodeAll for T where
T: Decode,
[src]
T: Decode,
impl<T> DecodeLimit for T where
T: Decode,
[src]
T: Decode,
pub fn decode_all_with_depth_limit(limit: u32, input: &[u8]) -> Result<T, Error>
[src]
pub fn decode_with_depth_limit(limit: u32, input: &[u8]) -> Result<T, Error>
[src]
impl<'_, '_, T> EncodeLike<&'_ &'_ T> for T where
T: Encode,
[src]
T: Encode,
impl<'_, T> EncodeLike<&'_ T> for T where
T: Encode,
[src]
T: Encode,
impl<'_, T> EncodeLike<&'_ mut T> for T where
T: Encode,
[src]
T: Encode,
impl<T> EncodeLike<Arc<T>> for T where
T: Encode,
[src]
T: Encode,
impl<T> EncodeLike<Box<T, Global>> for T where
T: Encode,
[src]
T: Encode,
impl<T> EncodeLike<Rc<T>> for T where
T: Encode,
[src]
T: Encode,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> KeyedVec for T where
T: Codec,
[src]
T: Codec,
impl<T> Pointable for T
pub const ALIGN: usize
type Init = T
The type for initializers.
pub unsafe fn init(init: <T as Pointable>::Init) -> usize
pub unsafe fn deref<'a>(ptr: usize) -> &'a T
pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
pub unsafe fn drop(ptr: usize)
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,