pub trait Idx: IdxBase {
const ZERO: Self;
const ONE: Self;
const MAX: Self;
const MIN: Self = Self::ZERO;
const RANGE: Range<Self> = _;
Show 24 methods
// Required methods
fn from_child_number(child_no: impl Into<u16>) -> Self;
fn try_from_child_number(
child_no: impl Into<u32>,
) -> Result<Self, IndexError>;
fn try_from_index(index: u32) -> Result<Self, IndexError>;
fn checked_add_assign(&mut self, add: impl Into<u32>) -> Option<Self>;
fn checked_sub_assign(&mut self, sub: impl Into<u32>) -> Option<Self>;
// Provided methods
fn to_be_bytes(&self) -> [u8; 4] { ... }
fn checked_inc(&self) -> Option<Self> { ... }
fn checked_dec(&self) -> Option<Self> { ... }
fn saturating_inc(&self) -> Self { ... }
fn saturating_dec(&self) -> Self { ... }
fn wrapping_inc(&self) -> Self { ... }
fn wrapping_dec(&self) -> Self { ... }
fn checked_inc_assign(&mut self) -> Option<Self> { ... }
fn checked_dec_assign(&mut self) -> Option<Self> { ... }
fn saturating_inc_assign(&mut self) -> bool { ... }
fn saturating_dec_assign(&mut self) -> bool { ... }
fn wrapping_inc_assign(&mut self) { ... }
fn wrapping_dec_assign(&mut self) { ... }
fn checked_add(&self, add: impl Into<u32>) -> Option<Self> { ... }
fn checked_sub(&self, sub: impl Into<u32>) -> Option<Self> { ... }
fn saturating_add(&self, add: impl Into<u32>) -> Self { ... }
fn saturating_sub(&self, sub: impl Into<u32>) -> Self { ... }
fn saturating_add_assign(&mut self, add: impl Into<u32>) -> bool { ... }
fn saturating_sub_assign(&mut self, sub: impl Into<u32>) -> bool { ... }
}
Expand description
Trait defining common API for different types of indexes which may be present in a certain derivation path segment: hardened, unhardened, mixed.
Required Associated Constants§
Provided Associated Constants§
Required Methods§
Sourcefn from_child_number(child_no: impl Into<u16>) -> Self
fn from_child_number(child_no: impl Into<u16>) -> Self
Constructs index from a given child number.
Child number is always a value in range of 0..
HARDENED_INDEX_BOUNDARY
Sourcefn try_from_child_number(child_no: impl Into<u32>) -> Result<Self, IndexError>
fn try_from_child_number(child_no: impl Into<u32>) -> Result<Self, IndexError>
Constructs index from a given child number.
Child number is always a value in range of 0..
HARDENED_INDEX_BOUNDARY
Sourcefn try_from_index(index: u32) -> Result<Self, IndexError>
fn try_from_index(index: u32) -> Result<Self, IndexError>
Constructs derivation path segment with specific derivation value, which
for normal indexes must lie in range 0..
HARDENED_INDEX_BOUNDARY
and for hardened in range of HARDENED_INDEX_BOUNDARY
..=u32::MAX
Sourcefn checked_add_assign(&mut self, add: impl Into<u32>) -> Option<Self>
fn checked_add_assign(&mut self, add: impl Into<u32>) -> Option<Self>
Mutates the self by adding value the index; fails if the index value overflow happens.
Sourcefn checked_sub_assign(&mut self, sub: impl Into<u32>) -> Option<Self>
fn checked_sub_assign(&mut self, sub: impl Into<u32>) -> Option<Self>
Mutates the self by subtracting value the index; fails if the index value overflow happens.
Provided Methods§
fn to_be_bytes(&self) -> [u8; 4]
Sourcefn checked_inc(&self) -> Option<Self>
fn checked_inc(&self) -> Option<Self>
Increments the index on one step; fails if the index value is already maximum value.
Sourcefn checked_dec(&self) -> Option<Self>
fn checked_dec(&self) -> Option<Self>
Decrements the index on one step; fails if the index value is already minimum value.
Sourcefn saturating_inc(&self) -> Self
fn saturating_inc(&self) -> Self
Increments the index on one step saturating at the Self::MAX
bounds
instead of overflowing.
Sourcefn saturating_dec(&self) -> Self
fn saturating_dec(&self) -> Self
Decrements the index on one step saturating at the Self::MIN
bounds
instead of overflowing.
Sourcefn wrapping_inc(&self) -> Self
fn wrapping_inc(&self) -> Self
Increments the index on one step; fails if the index value is already maximum value.
Sourcefn wrapping_dec(&self) -> Self
fn wrapping_dec(&self) -> Self
Decrements the index on one step; fails if the index value is already minimum value.
Sourcefn checked_inc_assign(&mut self) -> Option<Self>
fn checked_inc_assign(&mut self) -> Option<Self>
Mutates the self by incrementing the index on one step; fails if the index value is already maximum value.
Sourcefn checked_dec_assign(&mut self) -> Option<Self>
fn checked_dec_assign(&mut self) -> Option<Self>
Mutates the self by decrementing the index on one step; fails if the index value is already maximum value.
Sourcefn saturating_inc_assign(&mut self) -> bool
fn saturating_inc_assign(&mut self) -> bool
Mutates the self by incrementing the index on one step, saturating at the
Self::MAX
bounds instead of overflowing.
Sourcefn saturating_dec_assign(&mut self) -> bool
fn saturating_dec_assign(&mut self) -> bool
Mutates the self by decrementing the index on one step, saturating at the
Self::MIN
bounds instead of overflowing.
Sourcefn wrapping_inc_assign(&mut self)
fn wrapping_inc_assign(&mut self)
Mutates the self by incrementing the index on one step; fails if the index value is already maximum value.
Sourcefn wrapping_dec_assign(&mut self)
fn wrapping_dec_assign(&mut self)
Mutates the self by decrementing the index on one step; fails if the index value is already maximum value.
Sourcefn checked_add(&self, add: impl Into<u32>) -> Option<Self>
fn checked_add(&self, add: impl Into<u32>) -> Option<Self>
Adds value the index; fails if the index value overflow happens.
Sourcefn checked_sub(&self, sub: impl Into<u32>) -> Option<Self>
fn checked_sub(&self, sub: impl Into<u32>) -> Option<Self>
Subtracts value the index; fails if the index value overflow happens.
Sourcefn saturating_add(&self, add: impl Into<u32>) -> Self
fn saturating_add(&self, add: impl Into<u32>) -> Self
Saturating index addition. Computes self + add
, saturating at the
Self::MAX
bounds instead of overflowing.
Sourcefn saturating_sub(&self, sub: impl Into<u32>) -> Self
fn saturating_sub(&self, sub: impl Into<u32>) -> Self
Saturating index subtraction. Computes self - add
, saturating at
the Self::MIN
bounds instead of overflowing.
Sourcefn saturating_add_assign(&mut self, add: impl Into<u32>) -> bool
fn saturating_add_assign(&mut self, add: impl Into<u32>) -> bool
Mutates the self by adding value the index saturating it at the
Self::MAX
value in case of overflow. Returns boolean value
indicating if no overflow had happened.
Sourcefn saturating_sub_assign(&mut self, sub: impl Into<u32>) -> bool
fn saturating_sub_assign(&mut self, sub: impl Into<u32>) -> bool
Mutates the self by subtracting value from the index saturating
it at the Self::MIN
value in case of overflow. Returns boolean value
indicating if no overflow had happened.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.