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. CLValue
s, 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 URef
s 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
.
sourcepub fn as_account(&self) -> Option<&AccountHash>
pub fn as_account(&self) -> Option<&AccountHash>
Returns true if the key is of type Key::Account
.
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§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
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.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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)