Struct casper_types::account::associated_keys::AssociatedKeys
source · pub struct AssociatedKeys(/* private fields */);
Expand description
A mapping that represents the association of a Weight
with an AccountHash
.
Implementations§
source§impl AssociatedKeys
impl AssociatedKeys
sourcepub fn new(key: AccountHash, weight: Weight) -> AssociatedKeys
pub fn new(key: AccountHash, weight: Weight) -> AssociatedKeys
Constructs a new AssociatedKeys.
sourcepub fn add_key(
&mut self,
key: AccountHash,
weight: Weight
) -> Result<(), AddKeyFailure>
pub fn add_key( &mut self, key: AccountHash, weight: Weight ) -> Result<(), AddKeyFailure>
Adds new AssociatedKey to the set. Returns true if added successfully, false otherwise.
sourcepub fn remove_key(&mut self, key: &AccountHash) -> Result<(), RemoveKeyFailure>
pub fn remove_key(&mut self, key: &AccountHash) -> Result<(), RemoveKeyFailure>
Removes key from the associated keys set. Returns true if value was found in the set prior to the removal, false otherwise.
sourcepub fn update_key(
&mut self,
key: AccountHash,
weight: Weight
) -> Result<(), UpdateKeyFailure>
pub fn update_key( &mut self, key: AccountHash, weight: Weight ) -> Result<(), UpdateKeyFailure>
Adds new AssociatedKey to the set. Returns true if added successfully, false otherwise.
sourcepub fn get(&self, key: &AccountHash) -> Option<&Weight>
pub fn get(&self, key: &AccountHash) -> Option<&Weight>
Returns the weight of an account hash.
sourcepub fn contains_key(&self, key: &AccountHash) -> bool
pub fn contains_key(&self, key: &AccountHash) -> bool
Returns true
if a given key exists.
sourcepub fn iter(&self) -> impl Iterator<Item = (&AccountHash, &Weight)>
pub fn iter(&self) -> impl Iterator<Item = (&AccountHash, &Weight)>
Returns an iterator over the account hash and the weights.
sourcepub fn calculate_keys_weight(
&self,
authorization_keys: &BTreeSet<AccountHash>
) -> Weight
pub fn calculate_keys_weight( &self, authorization_keys: &BTreeSet<AccountHash> ) -> Weight
Calculates total weight of authorization keys provided by an argument
sourcepub fn total_keys_weight(&self) -> Weight
pub fn total_keys_weight(&self) -> Weight
Calculates total weight of all authorization keys
sourcepub fn total_keys_weight_excluding(&self, account_hash: AccountHash) -> Weight
pub fn total_keys_weight_excluding(&self, account_hash: AccountHash) -> Weight
Calculates total weight of all authorization keys excluding a given key
Trait Implementations§
source§impl Clone for AssociatedKeys
impl Clone for AssociatedKeys
source§fn clone(&self) -> AssociatedKeys
fn clone(&self) -> AssociatedKeys
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for AssociatedKeys
impl Debug for AssociatedKeys
source§impl Default for AssociatedKeys
impl Default for AssociatedKeys
source§fn default() -> AssociatedKeys
fn default() -> AssociatedKeys
Returns the “default value” for a type. Read more
source§impl<'de> Deserialize<'de> for AssociatedKeys
impl<'de> Deserialize<'de> for AssociatedKeys
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl From<AssociatedKeys> for BTreeMap<AccountHash, Weight>
impl From<AssociatedKeys> for BTreeMap<AccountHash, Weight>
source§fn from(associated_keys: AssociatedKeys) -> Self
fn from(associated_keys: AssociatedKeys) -> Self
Converts to this type from the input type.
source§impl From<BTreeMap<AccountHash, Weight>> for AssociatedKeys
impl From<BTreeMap<AccountHash, Weight>> for AssociatedKeys
source§impl FromBytes for AssociatedKeys
impl FromBytes for AssociatedKeys
source§impl Ord for AssociatedKeys
impl Ord for AssociatedKeys
source§fn cmp(&self, other: &AssociatedKeys) -> Ordering
fn cmp(&self, other: &AssociatedKeys) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl PartialEq for AssociatedKeys
impl PartialEq for AssociatedKeys
source§fn eq(&self, other: &AssociatedKeys) -> bool
fn eq(&self, other: &AssociatedKeys) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd for AssociatedKeys
impl PartialOrd for AssociatedKeys
source§fn partial_cmp(&self, other: &AssociatedKeys) -> Option<Ordering>
fn partial_cmp(&self, other: &AssociatedKeys) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
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 moresource§impl Serialize for AssociatedKeys
impl Serialize for AssociatedKeys
source§impl ToBytes for AssociatedKeys
impl ToBytes for AssociatedKeys
source§fn serialized_length(&self) -> usize
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.impl Eq for AssociatedKeys
impl StructuralEq for AssociatedKeys
impl StructuralPartialEq for AssociatedKeys
Auto Trait Implementations§
impl RefUnwindSafe for AssociatedKeys
impl Send for AssociatedKeys
impl Sync for AssociatedKeys
impl Unpin for AssociatedKeys
impl UnwindSafe for AssociatedKeys
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
Mutably borrows from an owned value. Read more