pub struct EraId(/* private fields */);Expand description
Era ID newtype.
Implementations§
Source§impl EraId
impl EraId
Sourcepub fn iter(&self, num_eras: u64) -> impl Iterator<Item = EraId>
pub fn iter(&self, num_eras: u64) -> impl Iterator<Item = EraId>
Returns an iterator over era IDs of num_eras future eras starting from current.
Sourcepub fn iter_inclusive(&self, num_eras: u64) -> impl Iterator<Item = EraId>
pub fn iter_inclusive(&self, num_eras: u64) -> impl Iterator<Item = EraId>
Returns an iterator over era IDs of num_eras future eras starting from current, plus the
provided one.
Sourcepub fn successor(self) -> EraId
pub fn successor(self) -> EraId
Returns a successor to current era.
For u64::MAX, this returns u64::MAX again: We want to make sure this doesn’t panic, and
that era number will never be reached in practice.
Sourcepub fn predecessor(self) -> Option<EraId>
pub fn predecessor(self) -> Option<EraId>
Returns the predecessor to current era, or None if genesis.
Sourcepub fn checked_add(&self, x: u64) -> Option<EraId>
pub fn checked_add(&self, x: u64) -> Option<EraId>
Returns the current era plus x, or None if that would overflow
Sourcepub fn checked_sub(&self, x: u64) -> Option<EraId>
pub fn checked_sub(&self, x: u64) -> Option<EraId>
Returns the current era minus x, or None if that would be less than 0.
Sourcepub fn saturating_sub(&self, x: u64) -> EraId
pub fn saturating_sub(&self, x: u64) -> EraId
Returns the current era minus x, or 0 if that would be less than 0.
Sourcepub fn saturating_add(self, rhs: u64) -> EraId
pub fn saturating_add(self, rhs: u64) -> EraId
Returns the current era plus x, or EraId::MAX if overflow would occur.
Sourcepub fn saturating_mul(&self, x: u64) -> EraId
pub fn saturating_mul(&self, x: u64) -> EraId
Returns the current era times x, or EraId::MAX if overflow would occur.
Sourcepub fn is_genesis(&self) -> bool
pub fn is_genesis(&self) -> bool
Returns whether this is era 0.
Sourcepub fn to_le_bytes(self) -> [u8; 8]
pub fn to_le_bytes(self) -> [u8; 8]
Returns little endian bytes.
Trait Implementations§
Source§impl AddAssign<u64> for EraId
impl AddAssign<u64> for EraId
Source§fn add_assign(&mut self, x: u64)
fn add_assign(&mut self, x: u64)
+= operation. Read moreSource§impl<'de> Deserialize<'de> for EraId
impl<'de> Deserialize<'de> for EraId
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>,
Source§impl Distribution<EraId> for Standard
impl Distribution<EraId> for Standard
Source§impl Ord for EraId
impl Ord for EraId
Source§impl PartialOrd for EraId
impl PartialOrd for EraId
Source§impl ToBytes for EraId
impl ToBytes for EraId
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.