Struct casper_types::EraId
source · 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§fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> EraId
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> EraId
T
, using rng
as the source of randomness.source§impl Ord for EraId
impl Ord for EraId
source§impl PartialEq for EraId
impl PartialEq for EraId
source§impl PartialOrd for EraId
impl PartialOrd for EraId
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§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.