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(no: impl Into<u16>) -> Self;
fn try_from_child_number(index: impl Into<u32>) -> Result<Self, IndexError>;
fn try_from_index(value: 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(no: impl Into<u16>) -> Self
fn from_child_number(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(index: impl Into<u32>) -> Result<Self, IndexError>
fn try_from_child_number(index: 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(value: u32) -> Result<Self, IndexError>
fn try_from_index(value: 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.