#[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. CLValue
s, 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
impl Key
Sourcepub const fn max_serialized_length() -> usize
pub const fn max_serialized_length() -> usize
Returns the maximum size a Key
can be serialized into.
Sourcepub fn normalize(self) -> Key
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.
Sourcepub fn to_formatted_string(self) -> String
pub fn to_formatted_string(self) -> String
Returns a human-readable version of self
, with the inner bytes encoded to Base16.
Sourcepub fn from_formatted_str(input: &str) -> Result<Key, FromStrError>
pub fn from_formatted_str(input: &str) -> Result<Key, FromStrError>
Parses a string formatted as per Self::to_formatted_string()
into a Key
.
Sourcepub fn into_account(self) -> Option<AccountHash>
pub fn into_account(self) -> Option<AccountHash>
Returns the inner bytes of self
if self
is of type Key::Account
, otherwise returns
None
.
Sourcepub fn into_hash_addr(self) -> Option<HashAddr>
pub fn into_hash_addr(self) -> Option<HashAddr>
Returns the inner bytes of self
if self
is of type Key::Hash
, otherwise returns
None
.
Sourcepub fn into_entity_hash_addr(self) -> Option<HashAddr>
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
.
Sourcepub fn into_package_addr(self) -> Option<PackageAddr>
pub fn into_package_addr(self) -> Option<PackageAddr>
Returns the inner bytes of self
if self
is of type Key::SmartContract
, otherwise
returns None
.
Sourcepub fn into_entity_hash(self) -> Option<AddressableEntityHash>
pub fn into_entity_hash(self) -> Option<AddressableEntityHash>
Returns AddressableEntityHash
of self
if self
is of type Key::AddressableEntity
,
otherwise returns None
.
Sourcepub fn into_package_hash(self) -> Option<PackageHash>
pub fn into_package_hash(self) -> Option<PackageHash>
Returns PackageHash
of self
if self
is of type Key::SmartContract
, otherwise
returns None
.
Sourcepub fn into_named_key_addr(self) -> Option<NamedKeyAddr>
pub fn into_named_key_addr(self) -> Option<NamedKeyAddr>
Returns NamedKeyAddr
of self
if self
is of type Key::NamedKey
, otherwise
returns None
.
Sourcepub fn as_uref_mut(&mut self) -> Option<&mut URef>
pub fn as_uref_mut(&mut self) -> Option<&mut URef>
Sourcepub fn as_balance(&self) -> Option<&URefAddr>
pub fn as_balance(&self) -> Option<&URefAddr>
Returns a reference to the inner URefAddr
if self
is of type Key::Balance
,
otherwise returns None
.
Sourcepub fn as_balance_hold(&self) -> Option<&BalanceHoldAddr>
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
.
Sourcepub fn as_dictionary(&self) -> Option<&DictionaryAddr>
pub fn as_dictionary(&self) -> Option<&DictionaryAddr>
Returns a reference to the inner DictionaryAddr
if self
is of type
Key::Dictionary
, otherwise returns None
.
Sourcepub fn as_bid_addr(&self) -> Option<&BidAddr>
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
.
Sourcepub fn as_message_topic_name_hash(&self) -> Option<TopicNameHash>
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
.
Sourcepub fn withdraw_to_unbond(&self) -> Option<Key>
pub fn withdraw_to_unbond(&self) -> Option<Key>
Casts a Key::Withdraw
to a Key::Unbond
Sourcepub fn dictionary(seed_uref: URef, dictionary_item_key: &[u8]) -> Key
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.
Sourcepub fn addressable_entity_key(
entity_kind_tag: EntityKindTag,
entity_hash: AddressableEntityHash,
) -> Self
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.
Sourcepub fn contract_entity_key(entity_hash: AddressableEntityHash) -> Key
pub fn contract_entity_key(entity_hash: AddressableEntityHash) -> Key
Creates a new Key::AddressableEntity
for a Smart contract.
Sourcepub fn byte_code_key(byte_code_addr: ByteCodeAddr) -> Self
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.
Sourcepub fn message(
entity_addr: EntityAddr,
topic_name_hash: TopicNameHash,
index: u32,
) -> Key
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
.
Sourcepub fn message_topic(
entity_addr: EntityAddr,
topic_name_hash: TopicNameHash,
) -> Key
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.
Sourcepub fn entry_point(entry_point_addr: EntryPointAddr) -> Self
pub fn entry_point(entry_point_addr: EntryPointAddr) -> Self
Creates a new Key::EntryPoint
variant from an entrypoint addr.
Sourcepub fn is_dictionary_key(&self) -> bool
pub fn is_dictionary_key(&self) -> bool
Returns true if the key is of type Key::Dictionary
.
Sourcepub fn is_balance_key(&self) -> bool
pub fn is_balance_key(&self) -> bool
Returns true if the key is of type Key::Bid
.
Sourcepub fn is_bid_addr_key(&self) -> bool
pub fn is_bid_addr_key(&self) -> bool
Returns true if the key is of type Key::BidAddr
.
Sourcepub fn is_named_key(&self) -> bool
pub fn is_named_key(&self) -> bool
Returns true if the key is of type Key::NamedKey
.
Sourcepub fn is_system_key(&self) -> bool
pub fn is_system_key(&self) -> bool
Returns if the inner address is for a system contract entity.
Sourcepub fn is_smart_contract_key(&self) -> bool
pub fn is_smart_contract_key(&self) -> bool
Return true if the inner Key is of the smart contract type.
Sourcepub fn is_named_key_entry(&self) -> bool
pub fn is_named_key_entry(&self) -> bool
Returns true if the key is of type Key::NamedKey
and its Entry variant.
Sourcepub fn is_entry_for_base(&self, entity_addr: &EntityAddr) -> bool
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
.
Sourcepub fn is_readable(&self, entity_addr: &EntityAddr) -> bool
pub fn is_readable(&self, entity_addr: &EntityAddr) -> bool
Is the record under this key readable by the entity corresponding to the imputed address?
Sourcepub fn is_addable(&self, entity_addr: &EntityAddr) -> bool
pub fn is_addable(&self, entity_addr: &EntityAddr) -> bool
Is the record under this key addable by the entity corresponding to the imputed address?
Sourcepub fn is_writeable(&self, entity_addr: &EntityAddr) -> bool
pub fn is_writeable(&self, entity_addr: &EntityAddr) -> bool
Is the record under this key writeable by the entity corresponding to the imputed address?
Sourcepub fn into_entity_addr(self) -> Option<EntityAddr>
pub fn into_entity_addr(self) -> Option<EntityAddr>
Returns an entity addr for a Key::AddressableEntity
.
Trait Implementations§
Source§impl DataSize for Keywhere
AccountHash: DataSize,
HashAddr: DataSize,
URef: DataSize,
TransferAddr: DataSize,
DeployHash: DataSize,
EraId: DataSize,
URefAddr: DataSize,
DictionaryAddr: DataSize,
BidAddr: DataSize,
PackageAddr: DataSize,
EntityAddr: DataSize,
ByteCodeAddr: DataSize,
MessageAddr: DataSize,
NamedKeyAddr: DataSize,
BlockGlobalAddr: DataSize,
BalanceHoldAddr: DataSize,
EntryPointAddr: DataSize,
impl DataSize for Keywhere
AccountHash: DataSize,
HashAddr: DataSize,
URef: DataSize,
TransferAddr: DataSize,
DeployHash: DataSize,
EraId: DataSize,
URefAddr: DataSize,
DictionaryAddr: DataSize,
BidAddr: DataSize,
PackageAddr: DataSize,
EntityAddr: DataSize,
ByteCodeAddr: DataSize,
MessageAddr: DataSize,
NamedKeyAddr: DataSize,
BlockGlobalAddr: DataSize,
BalanceHoldAddr: DataSize,
EntryPointAddr: DataSize,
Source§const IS_DYNAMIC: bool = true
const IS_DYNAMIC: bool = true
true
, the type has a heap size that can vary at runtime, depending on the actual value.Source§const STATIC_HEAP_SIZE: usize = 0usize
const STATIC_HEAP_SIZE: usize = 0usize
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
fn estimate_heap_size(&self) -> usize
Source§impl<'de> Deserialize<'de> for Key
impl<'de> Deserialize<'de> for Key
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Source§impl Distribution<Key> for Standard
Available on crate feature testing
only.
impl Distribution<Key> for Standard
testing
only.Source§impl From<AccountHash> for Key
impl From<AccountHash> for Key
Source§fn from(account_hash: AccountHash) -> Key
fn from(account_hash: AccountHash) -> Key
Source§impl From<BalanceHoldAddr> for Key
impl From<BalanceHoldAddr> for Key
Source§fn from(balance_hold_addr: BalanceHoldAddr) -> Self
fn from(balance_hold_addr: BalanceHoldAddr) -> Self
Source§impl From<BlockGlobalAddr> for Key
impl From<BlockGlobalAddr> for Key
Source§fn from(block_global_addr: BlockGlobalAddr) -> Self
fn from(block_global_addr: BlockGlobalAddr) -> Self
Source§impl From<ByteCodeAddr> for Key
impl From<ByteCodeAddr> for Key
Source§fn from(value: ByteCodeAddr) -> Self
fn from(value: ByteCodeAddr) -> Self
Source§impl From<ContractHash> for Key
impl From<ContractHash> for Key
Source§fn from(contract_hash: ContractHash) -> Self
fn from(contract_hash: ContractHash) -> Self
Source§impl From<ContractPackageHash> for Key
impl From<ContractPackageHash> for Key
Source§fn from(contract_package_hash: ContractPackageHash) -> Self
fn from(contract_package_hash: ContractPackageHash) -> Self
Source§impl From<ContractWasmHash> for Key
impl From<ContractWasmHash> for Key
Source§fn from(wasm_hash: ContractWasmHash) -> Self
fn from(wasm_hash: ContractWasmHash) -> Self
Source§impl From<EntityAddr> for Key
impl From<EntityAddr> for Key
Source§fn from(entity_addr: EntityAddr) -> Self
fn from(entity_addr: EntityAddr) -> Self
Source§impl From<NamedKeyAddr> for Key
impl From<NamedKeyAddr> for Key
Source§fn from(value: NamedKeyAddr) -> Self
fn from(value: NamedKeyAddr) -> Self
Source§impl From<PackageHash> for Key
impl From<PackageHash> for Key
Source§fn from(package_hash: PackageHash) -> Key
fn from(package_hash: PackageHash) -> Key
Source§impl JsonSchema for Key
Available on crate feature json-schema
only.
impl JsonSchema for Key
json-schema
only.Source§fn schema_name() -> String
fn schema_name() -> String
Source§fn json_schema(gen: &mut SchemaGenerator) -> Schema
fn json_schema(gen: &mut SchemaGenerator) -> Schema
Source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
$ref
keyword. Read moreSource§impl Ord for Key
impl Ord for Key
Source§impl PartialOrd for Key
impl PartialOrd for Key
Source§impl ToBytes for Key
impl ToBytes for Key
Source§fn serialized_length(&self) -> usize
fn serialized_length(&self) -> usize
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§impl TryFrom<Key> for AddressableEntityHash
impl TryFrom<Key> for AddressableEntityHash
Source§impl TryFrom<Key> for BalanceHoldAddr
Available on crate feature std
only.
impl TryFrom<Key> for BalanceHoldAddr
std
only.Source§impl TryFrom<Key> for BlockGlobalAddr
Available on crate feature std
only.
impl TryFrom<Key> for BlockGlobalAddr
std
only.impl Copy for Key
impl Eq for Key
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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