Struct ink_primitives::KeyComposer

source ·
pub struct KeyComposer;
Expand description

Contains all rules related to storage key creation.

Implementations§

source§

impl KeyComposer

source

pub const fn concat(left: Key, right: Key) -> Key

Concatenate two Key into one during compilation.

source

pub const fn from_str(str: &str) -> Key

Return the storage key from the supplied str.

source

pub const fn from_bytes(bytes: &[u8]) -> Key

Returns the storage key from the supplied bytes.

source

pub fn compute_key( struct_name: &str, variant_name: &str, field_name: &str, ) -> Result<Key, Error>

Evaluates the storage key of the field in the structure, variant or union.

  1. Compute the ASCII byte representation of struct_name and call it S.
  2. If variant_name is not empty then computes the ASCII byte representation and call it V. 1. Compute the ASCII byte representation of field_name and call it F. 1. Concatenate (S and F) or (S, V and F) using :: as separator and call it C. 1. The XXH32 hash of C is the storage key.
§Note
  • variant_name is empty for structures and unions.
  • if the field is unnamed then field_name is "{}" where {} is a number of the field.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> JsonSchemaMaybe for T