[][src]Enum casperlabs_types::Key

#[repr(C)]pub enum Key {
    Account(PublicKey),
    Hash([u8; 32]),
    URef(URef),
    Local {
        seed: [u8; 32],
        hash: [u8; 32],
    },
}

The type under which data (e.g. CLValues, smart contracts, user accounts) are indexed on the network.

Variants

Account(PublicKey)

A Key under which a user account is stored.

Hash([u8; 32])

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.

Local

A Key to data (normally a CLValue) which is held in local-storage rather than global-storage.

Fields of Local

seed: [u8; 32]

A value derived from the base key defining the local context.

hash: [u8; 32]

A hash identifying the stored data.

Methods

impl Key[src]

pub fn local(seed: [u8; 32], key_bytes: &[u8]) -> Self[src]

Constructs a new Key::Local by hashing seed concatenated with key_bytes.

pub const fn max_serialized_length() -> usize[src]

Returns the maximum size a Key can be serialized into.

pub fn normalize(self) -> Key[src]

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

pub fn as_string(&self) -> String[src]

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

pub fn to_contract_ref(self) -> Option<ContractRef>[src]

Consumes and converts self to a ContractRef if self is of type Key::Hash or Key::URef, otherwise returns None.

pub fn into_account(self) -> Option<PublicKey>[src]

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

pub fn into_hash(self) -> Option<[u8; 32]>[src]

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

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

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

pub fn into_uref(self) -> Option<URef>[src]

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

pub fn into_local(self) -> Option<[u8; 64]>[src]

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

Trait Implementations

impl CLTyped for Key[src]

impl Clone for Key[src]

impl Copy for Key[src]

impl Debug for Key[src]

impl Display for Key[src]

impl Eq for Key[src]

impl From<ContractRef> for Key[src]

impl From<URef> for Key[src]

impl FromBytes for Key[src]

impl Hash for Key[src]

impl Ord for Key[src]

impl PartialEq<Key> for Key[src]

impl PartialOrd<Key> for Key[src]

impl StructuralEq for Key[src]

impl StructuralPartialEq for Key[src]

impl ToBytes for Key[src]

impl TryFrom<Key> for URef[src]

type Error = ApiError

The type returned in the event of a conversion error.

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.