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

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(self) -> Option<HashAddr>

Returns the inner bytes of self if self is of type Key::Hash, 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 into_uref(self) -> Option<URef>

Returns the inner URef if self is of type Key::URef, 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 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 is_dictionary_key(&self) -> bool

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

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

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<ContractHash> for Key

source§

fn from(contract_hash: ContractHash) -> Key

Converts to this type from the input type.
source§

impl From<ContractPackageHash> for Key

source§

fn from(package_hash: ContractPackageHash) -> Key

Converts to this type from the input type.
source§

impl From<ContractWasmHash> for Key

source§

fn from(wasm_hash: ContractWasmHash) -> Key

Converts to this type from the input type.
source§

impl From<TransferAddr> for Key

source§

fn from(transfer_addr: TransferAddr) -> 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 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) -> Selfwhere Self: Sized,

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

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

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

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd,

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

impl PartialEq for Key

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method 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

This method 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

This method 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

This method 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

This method 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 URef

§

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 StructuralEq for Key

source§

impl StructuralPartialEq for Key

Auto Trait Implementations§

§

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 Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

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 Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

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

impl<T, U> TryFrom<U> for Twhere 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 Twhere 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.
source§

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