Enum Key

Source
#[repr(C)]
pub enum Key {
Show 25 variants Account(AccountHash), Hash(HashAddr), URef(URef), Transfer(TransferAddr), DeployInfo(DeployHash), EraInfo(EraId), Balance(URefAddr), Bid(AccountHash), Withdraw(AccountHash), Dictionary(DictionaryAddr), SystemEntityRegistry, EraSummary, Unbond(AccountHash), ChainspecRegistry, ChecksumRegistry, BidAddr(BidAddr), SmartContract(PackageAddr), AddressableEntity(EntityAddr), ByteCode(ByteCodeAddr), Message(MessageAddr), NamedKey(NamedKeyAddr), BlockGlobal(BlockGlobalAddr), BalanceHold(BalanceHoldAddr), EntryPoint(EntryPointAddr), State(EntityAddr),
}
Expand description

The key under which data (e.g. CLValues, smart contracts, user accounts) are stored in global state.

Variants§

§

Account(AccountHash)

A Key under which a user account is stored.

§

Hash(HashAddr)

A Key under which a smart contract is stored and which is the pseudo-hash of the contract.

§

URef(URef)

A Key which is a URef, under which most types of data can be stored.

§

Transfer(TransferAddr)

A Key under which a transfer is stored.

§

DeployInfo(DeployHash)

A Key under which a deploy info is stored.

§

EraInfo(EraId)

A Key under which an era info is stored.

§

Balance(URefAddr)

A Key under which a purse balance is stored.

§

Bid(AccountHash)

A Key under which bid information is stored.

§

Withdraw(AccountHash)

A Key under which withdraw information is stored.

§

Dictionary(DictionaryAddr)

A Key whose value is derived by hashing a URef address and arbitrary data, under which a dictionary is stored.

§

SystemEntityRegistry

A Key under which system entity hashes are stored.

§

EraSummary

A Key under which current era info is stored.

§

Unbond(AccountHash)

A Key under which unbond information is stored.

§

ChainspecRegistry

A Key under which chainspec and other hashes are stored.

§

ChecksumRegistry

A Key under which a registry of checksums is stored.

§

BidAddr(BidAddr)

A Key under which bid information is stored.

§

SmartContract(PackageAddr)

A Key under which package information is stored.

§

AddressableEntity(EntityAddr)

A Key under which an addressable entity is stored.

§

ByteCode(ByteCodeAddr)

A Key under which a byte code record is stored.

§

Message(MessageAddr)

A Key under which a message is stored.

§

NamedKey(NamedKeyAddr)

A Key under which a single named key entry is stored.

§

BlockGlobal(BlockGlobalAddr)

A Key under which per-block details are stored to global state.

§

BalanceHold(BalanceHoldAddr)

A Key under which a hold on a purse balance is stored.

§

EntryPoint(EntryPointAddr)

A Key under which a entrypoint record is written.

§

State(EntityAddr)

A Key under which a contract’s state lives.

Implementations§

Source§

impl Key

Source

pub const fn max_serialized_length() -> usize

Returns the maximum size a Key can be serialized into.

Source

pub fn normalize(self) -> Key

If self is of type Key::URef, returns self with the AccessRights stripped from the wrapped URef, otherwise returns self unmodified.

Source

pub fn to_formatted_string(self) -> String

Returns a human-readable version of self, with the inner bytes encoded to Base16.

Source

pub fn from_formatted_str(input: &str) -> Result<Key, FromStrError>

Parses a string formatted as per Self::to_formatted_string() into a Key.

Source

pub fn into_account(self) -> Option<AccountHash>

Returns the inner bytes of self if self is of type Key::Account, otherwise returns None.

Source

pub fn into_hash_addr(self) -> Option<HashAddr>

Returns the inner bytes of self if self is of type Key::Hash, otherwise returns None.

Source

pub fn into_entity_hash_addr(self) -> Option<HashAddr>

Returns the inner bytes of self if self is of type Key::AddressableEntity, otherwise returns None.

Source

pub fn into_package_addr(self) -> Option<PackageAddr>

Returns the inner bytes of self if self is of type Key::SmartContract, otherwise returns None.

Source

pub fn into_entity_hash(self) -> Option<AddressableEntityHash>

Returns AddressableEntityHash of self if self is of type Key::AddressableEntity, otherwise returns None.

Source

pub fn into_package_hash(self) -> Option<PackageHash>

Returns PackageHash of self if self is of type Key::SmartContract, otherwise returns None.

Source

pub fn into_named_key_addr(self) -> Option<NamedKeyAddr>

Returns NamedKeyAddr of self if self is of type Key::NamedKey, otherwise returns None.

Source

pub fn into_uref(self) -> Option<URef>

Returns the inner URef if self is of type Key::URef, otherwise returns None.

Source

pub fn as_uref(&self) -> Option<&URef>

Returns a reference to the inner URef if self is of type Key::URef, otherwise returns None.

Source

pub fn as_uref_mut(&mut self) -> Option<&mut URef>

Returns a reference to the inner URef if self is of type Key::URef, otherwise returns None.

Source

pub fn as_balance(&self) -> Option<&URefAddr>

Returns a reference to the inner URefAddr if self is of type Key::Balance, otherwise returns None.

Source

pub fn as_balance_hold(&self) -> Option<&BalanceHoldAddr>

Returns a reference to the inner BalanceHoldAddr if self is of type Key::BalanceHold, otherwise returns None.

Source

pub fn as_dictionary(&self) -> Option<&DictionaryAddr>

Returns a reference to the inner DictionaryAddr if self is of type Key::Dictionary, otherwise returns None.

Source

pub fn as_bid_addr(&self) -> Option<&BidAddr>

Returns a reference to the inner BidAddr if self is of type Key::Bid, otherwise returns None.

Source

pub fn as_message_topic_name_hash(&self) -> Option<TopicNameHash>

Returns a reference to the inner TopicNameHash if self is of the type Key::Message otherwise returns None.

Source

pub fn uref_to_hash(&self) -> Option<Key>

Casts a Key::URef to a Key::Hash

Source

pub fn withdraw_to_unbond(&self) -> Option<Key>

Source

pub fn dictionary(seed_uref: URef, dictionary_item_key: &[u8]) -> Key

Creates a new Key::Dictionary variant based on a seed_uref and a dictionary_item_key bytes.

Source

pub fn addressable_entity_key( entity_kind_tag: EntityKindTag, entity_hash: AddressableEntityHash, ) -> Self

Creates a new Key::AddressableEntity variant from a package kind and an entity hash.

Source

pub fn contract_entity_key(entity_hash: AddressableEntityHash) -> Key

Creates a new Key::AddressableEntity for a Smart contract.

Source

pub fn byte_code_key(byte_code_addr: ByteCodeAddr) -> Self

Creates a new Key::ByteCode variant from a byte code kind and an byte code addr.

Source

pub fn message( entity_addr: EntityAddr, topic_name_hash: TopicNameHash, index: u32, ) -> Key

Creates a new Key::Message variant that identifies an indexed message based on an hash_addr, topic_name_hash and message index.

Source

pub fn message_topic( entity_addr: EntityAddr, topic_name_hash: TopicNameHash, ) -> Key

Creates a new Key::Message variant that identifies a message topic based on an hash_addr and a hash of the topic name.

Source

pub fn entry_point(entry_point_addr: EntryPointAddr) -> Self

Creates a new Key::EntryPoint variant from an entrypoint addr.

Source

pub fn is_dictionary_key(&self) -> bool

Returns true if the key is of type Key::Dictionary.

Source

pub fn is_balance_key(&self) -> bool

Returns true if the key is of type Key::Bid.

Source

pub fn is_bid_addr_key(&self) -> bool

Returns true if the key is of type Key::BidAddr.

Source

pub fn is_named_key(&self) -> bool

Returns true if the key is of type Key::NamedKey.

Source

pub fn is_system_key(&self) -> bool

Returns if the inner address is for a system contract entity.

Source

pub fn is_smart_contract_key(&self) -> bool

Return true if the inner Key is of the smart contract type.

Source

pub fn is_named_key_entry(&self) -> bool

Returns true if the key is of type Key::NamedKey and its Entry variant.

Source

pub fn is_entry_for_base(&self, entity_addr: &EntityAddr) -> bool

Returns true if the key is of type Key::NamedKey and the variants have the same EntityAddr.

Source

pub fn is_readable(&self, entity_addr: &EntityAddr) -> bool

Is the record under this key readable by the entity corresponding to the imputed address?

Source

pub fn is_addable(&self, entity_addr: &EntityAddr) -> bool

Is the record under this key addable by the entity corresponding to the imputed address?

Source

pub fn is_writeable(&self, entity_addr: &EntityAddr) -> bool

Is the record under this key writeable by the entity corresponding to the imputed address?

Source

pub fn into_entity_addr(self) -> Option<EntityAddr>

Returns an entity addr for a Key::AddressableEntity.

Trait Implementations§

Source§

impl CLTyped for Key

Source§

fn cl_type() -> CLType

The CLType of Self.
Source§

impl Clone for Key

Source§

fn clone(&self) -> Key

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl DataSize for Key

Source§

const IS_DYNAMIC: bool = true

If true, the type has a heap size that can vary at runtime, depending on the actual value.
Source§

const STATIC_HEAP_SIZE: usize = 0usize

The amount of space a value of the type always occupies. If IS_DYNAMIC is false, this is the total amount of heap memory occupied by the value. Otherwise this is a lower bound.
Source§

fn estimate_heap_size(&self) -> usize

Estimates the size of heap memory taken up by this value. Read more
Source§

impl Debug for Key

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Key

Source§

fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Key

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Distribution<Key> for Standard

Available on crate feature testing only.
Source§

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Key

Generate a random value of T, using rng as the source of randomness.
Source§

fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
Source§

fn map<F, S>(self, func: F) -> DistMap<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Create a distribution of values of ‘S’ by mapping the output of Self through the closure F Read more
Source§

impl From<AccountHash> for Key

Source§

fn from(account_hash: AccountHash) -> Key

Converts to this type from the input type.
Source§

impl From<BalanceHoldAddr> for Key

Source§

fn from(balance_hold_addr: BalanceHoldAddr) -> Self

Converts to this type from the input type.
Source§

impl From<BidAddr> for Key

Source§

fn from(bid_addr: BidAddr) -> Self

Converts to this type from the input type.
Source§

impl From<BlockGlobalAddr> for Key

Source§

fn from(block_global_addr: BlockGlobalAddr) -> Self

Converts to this type from the input type.
Source§

impl From<ByteCodeAddr> for Key

Source§

fn from(value: ByteCodeAddr) -> Self

Converts to this type from the input type.
Source§

impl From<ContractHash> for Key

Source§

fn from(contract_hash: ContractHash) -> Self

Converts to this type from the input type.
Source§

impl From<ContractPackageHash> for Key

Source§

fn from(contract_package_hash: ContractPackageHash) -> Self

Converts to this type from the input type.
Source§

impl From<ContractWasmHash> for Key

Source§

fn from(wasm_hash: ContractWasmHash) -> Self

Converts to this type from the input type.
Source§

impl From<EntityAddr> for Key

Source§

fn from(entity_addr: EntityAddr) -> Self

Converts to this type from the input type.
Source§

impl From<NamedKeyAddr> for Key

Source§

fn from(value: NamedKeyAddr) -> Self

Converts to this type from the input type.
Source§

impl From<PackageHash> for Key

Source§

fn from(package_hash: PackageHash) -> Key

Converts to this type from the input type.
Source§

impl From<URef> for Key

Source§

fn from(uref: URef) -> Key

Converts to this type from the input type.
Source§

impl FromBytes for Key

Source§

fn from_bytes(bytes: &[u8]) -> Result<(Self, &[u8]), Error>

Deserializes the slice into Self.
Source§

fn from_vec(bytes: Vec<u8>) -> Result<(Self, Vec<u8>), Error>

Deserializes the Vec<u8> into Self.
Source§

impl Hash for Key

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl JsonSchema for Key

Available on crate feature json-schema only.
Source§

fn schema_name() -> String

The name of the generated JSON Schema. Read more
Source§

fn json_schema(gen: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
Source§

fn is_referenceable() -> bool

Whether JSON Schemas generated for this type should be re-used where possible using the $ref keyword. Read more
Source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
Source§

impl Ord for Key

Source§

fn cmp(&self, other: &Key) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Key

Source§

fn eq(&self, other: &Key) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Key

Source§

fn partial_cmp(&self, other: &Key) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Serialize for Key

Source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more
Source§

impl Tagged<KeyTag> for Key

Source§

fn tag(&self) -> KeyTag

Returns the tag of a given object
Source§

impl Tagged<u8> for Key

Source§

fn tag(&self) -> u8

Returns the tag of a given object
Source§

impl ToBytes for Key

Source§

fn to_bytes(&self) -> Result<Vec<u8>, Error>

Serializes &self to a Vec<u8>.
Source§

fn serialized_length(&self) -> usize

Returns the length of the Vec<u8> which would be returned from a successful call to to_bytes() or into_bytes(). The data is not actually serialized, so this call is relatively cheap.
Source§

fn write_bytes(&self, writer: &mut Vec<u8>) -> Result<(), Error>

Writes &self into a mutable writer.
Source§

fn into_bytes(self) -> Result<Vec<u8>, Error>
where Self: Sized,

Consumes self and serializes to a Vec<u8>.
Source§

impl TryFrom<Key> for AddressableEntityHash

Source§

type Error = ApiError

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

fn try_from(value: Key) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Key> for BalanceHoldAddr

Available on crate feature std only.
Source§

type Error = ()

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

fn try_from(value: Key) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Key> for BlockGlobalAddr

Available on crate feature std only.
Source§

type Error = ()

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

fn try_from(value: Key) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Key> for URef

Source§

type Error = ApiError

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

fn try_from(key: Key) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl Copy for Key

Source§

impl Eq for Key

Source§

impl StructuralPartialEq for Key

Auto Trait Implementations§

§

impl Freeze for Key

§

impl RefUnwindSafe for Key

§

impl Send for Key

§

impl Sync for Key

§

impl Unpin for Key

§

impl UnwindSafe for Key

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

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>,

Source§

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.
Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,