Trait bpstd::Idx

source ·
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§

source

const ZERO: Self

Derivation path segment with index equal to zero.

source

const ONE: Self

Derivation path segment with index equal to one.

source

const MAX: Self

Derivation path segment with index equal to maximum value.

Provided Associated Constants§

source

const MIN: Self = Self::ZERO

Derivation path segment with index equal to minimal value.

source

const RANGE: Range<Self> = _

Range covering all possible index values.

Required Methods§

source

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

source

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

source

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

source

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.

source

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§

source

fn to_be_bytes(&self) -> [u8; 4]

source

fn checked_inc(&self) -> Option<Self>

Increments the index on one step; fails if the index value is already maximum value.

source

fn checked_dec(&self) -> Option<Self>

Decrements the index on one step; fails if the index value is already minimum value.

source

fn saturating_inc(&self) -> Self

Increments the index on one step saturating at the Self::MAX bounds instead of overflowing.

source

fn saturating_dec(&self) -> Self

Decrements the index on one step saturating at the Self::MIN bounds instead of overflowing.

source

fn wrapping_inc(&self) -> Self

Increments the index on one step; fails if the index value is already maximum value.

source

fn wrapping_dec(&self) -> Self

Decrements the index on one step; fails if the index value is already minimum value.

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

fn checked_add(&self, add: impl Into<u32>) -> Option<Self>

Adds value the index; fails if the index value overflow happens.

source

fn checked_sub(&self, sub: impl Into<u32>) -> Option<Self>

Subtracts value the index; fails if the index value overflow happens.

source

fn saturating_add(&self, add: impl Into<u32>) -> Self

Saturating index addition. Computes self + add, saturating at the Self::MAX bounds instead of overflowing.

source

fn saturating_sub(&self, sub: impl Into<u32>) -> Self

Saturating index subtraction. Computes self - add, saturating at the Self::MIN bounds instead of overflowing.

source

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.

source

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.

Object Safety§

This trait is not object safe.

Implementors§