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 iter_range_inclusive(
start: EraId,
end: EraId,
) -> impl DoubleEndedIterator<Item = EraId>
pub fn iter_range_inclusive( start: EraId, end: EraId, ) -> impl DoubleEndedIterator<Item = EraId>
Returns an iterator over a range of era IDs, starting from start and ending at end,
inclusive.
Sourcepub fn increment(&mut self)
pub fn increment(&mut self)
Increments the 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 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 Arbitrary for EraId
impl Arbitrary for EraId
Source§type Parameters = <u64 as Arbitrary>::Parameters
type Parameters = <u64 as Arbitrary>::Parameters
arbitrary_with accepts for configuration
of the generated Strategy. Parameters must implement Default.Source§type Strategy = Map<<u64 as Arbitrary>::Strategy, fn(u64) -> EraId>
type Strategy = Map<<u64 as Arbitrary>::Strategy, fn(u64) -> EraId>
Strategy used to generate values of type Self.Source§fn arbitrary_with(_top: Self::Parameters) -> Self::Strategy
fn arbitrary_with(_top: Self::Parameters) -> Self::Strategy
Source§impl DataSize for EraId
impl DataSize for EraId
Source§const IS_DYNAMIC: bool = false
const IS_DYNAMIC: bool = false
true, the type has a heap size that can vary at runtime, depending on the actual value.Source§const STATIC_HEAP_SIZE: usize = 0usize
const STATIC_HEAP_SIZE: usize = 0usize
IS_DYNAMIC is false, this is
the total amount of heap memory occupied by the value. Otherwise this is a lower bound.Source§fn estimate_heap_size(&self) -> usize
fn estimate_heap_size(&self) -> usize
Source§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 JsonSchema for EraId
impl JsonSchema for EraId
Source§fn schema_name() -> String
fn schema_name() -> String
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
$ref keyword. Read moreSource§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.impl Copy for EraId
impl Eq for EraId
impl StructuralPartialEq for EraId
Auto Trait Implementations§
impl Freeze for EraId
impl RefUnwindSafe for EraId
impl Send for EraId
impl Sync for EraId
impl Unpin for EraId
impl UnwindSafe for EraId
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more