Enum casper_types::Key
source · #[repr(C)]pub enum Key {
Show 15 variants
Account(AccountHash),
Hash(HashAddr),
URef(URef),
Transfer(TransferAddr),
DeployInfo(DeployHash),
EraInfo(EraId),
Balance(URefAddr),
Bid(AccountHash),
Withdraw(AccountHash),
Dictionary(DictionaryAddr),
SystemContractRegistry,
EraSummary,
Unbond(AccountHash),
ChainspecRegistry,
ChecksumRegistry,
}Expand description
The type under which data (e.g. CLValues, smart contracts, user accounts)
are indexed on the network.
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 we store a transfer.
DeployInfo(DeployHash)
A Key under which we store a deploy info.
EraInfo(EraId)
A Key under which we store an era info.
Balance(URefAddr)
A Key under which we store a purse balance.
Bid(AccountHash)
A Key under which we store bid information
Withdraw(AccountHash)
A Key under which we store withdraw information.
Dictionary(DictionaryAddr)
A Key variant whose value is derived by hashing URefs address and arbitrary data.
SystemContractRegistry
A Key variant under which system contract hashes are stored.
EraSummary
A Key under which we store current era info.
Unbond(AccountHash)
A Key under which we store unbond information.
ChainspecRegistry
A Key variant under which chainspec and other hashes are stored.
ChecksumRegistry
A Key variant under which we store a registry of checksums.
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(self) -> Option<HashAddr>
pub fn into_hash(self) -> Option<HashAddr>
Returns the inner bytes of self if self is of type Key::Hash, 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_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 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 is_dictionary_key(&self) -> bool
pub fn is_dictionary_key(&self) -> bool
Returns true if the key is of type Key::Dictionary.
Trait Implementations§
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
impl Distribution<Key> for Standard
source§fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Key
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Key
T, using rng as the source of randomness.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<ContractHash> for Key
impl From<ContractHash> for Key
source§fn from(contract_hash: ContractHash) -> Key
fn from(contract_hash: ContractHash) -> Key
source§impl From<ContractPackageHash> for Key
impl From<ContractPackageHash> for Key
source§fn from(package_hash: ContractPackageHash) -> Key
fn from(package_hash: ContractPackageHash) -> Key
source§impl From<ContractWasmHash> for Key
impl From<ContractWasmHash> for Key
source§fn from(wasm_hash: ContractWasmHash) -> Key
fn from(wasm_hash: ContractWasmHash) -> Key
source§impl From<TransferAddr> for Key
impl From<TransferAddr> for Key
source§fn from(transfer_addr: TransferAddr) -> Key
fn from(transfer_addr: TransferAddr) -> Key
source§impl Ord for Key
impl Ord for Key
source§impl PartialOrd for Key
impl PartialOrd for Key
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <=
operator. Read moresource§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.