Struct chain_path_derivation::Derivation 
source · pub struct Derivation(u32);Expand description
a derivation value that can be used to derive keys
There is 2 kind of derivations, the soft and the hard derivations.
SoftDerivation are expected to allow derivation of the private
keys and of the public keys. HardDerivation are expected to allow
only the derivation of the private keys.
Tuple Fields§
§0: u32Implementations§
source§impl Derivation
 
impl Derivation
sourcepub fn is_soft_derivation(self) -> bool
 
pub fn is_soft_derivation(self) -> bool
test if the given derivation is a soft derivation
Example
let derivation = Derivation::new(42);
assert!(derivation.is_soft_derivation());sourcepub fn is_hard_derivation(self) -> bool
 
pub fn is_hard_derivation(self) -> bool
test if the given derivation is a hard derivation
Example
let derivation = Derivation::new(0x8000_0010);
assert!(derivation.is_hard_derivation());sourcepub const fn max_value() -> Self
 
pub const fn max_value() -> Self
returns the max derivation index value
let max = Derivation::max_value();
assert_eq!(max, Derivation::new(4294967295));sourcepub const fn min_value() -> Self
 
pub const fn min_value() -> Self
returns the min derivation index value
let min = Derivation::min_value();
assert_eq!(min, Derivation::new(0));sourcepub const fn overflowing_add(self, rhs: u32) -> (Self, bool)
 
pub const fn overflowing_add(self, rhs: u32) -> (Self, bool)
calculate derivation + rhs
Returns the tuple of the addition along with a boolean indicating whether an arithmetic overflow would occur. If an overflow would have occurred then the wrapped value is returned.
Examples
Basic usage:
assert_eq!(
    Derivation::new(5).overflowing_add(2),
    (Derivation::new(7), false)
);
assert_eq!(
    Derivation::max_value().overflowing_add(1),
    (Derivation::new(0), true)
);sourcepub fn saturating_add(self, rhs: u32) -> Self
 
pub fn saturating_add(self, rhs: u32) -> Self
saturating integer addition. Computes self + rhs, saturating
at the numeric bounds instead of overflowing.
Examples
Basic usage:
assert_eq!(Derivation::new(100).saturating_add(1), Derivation::new(101));
assert_eq!(Derivation::max_value().saturating_add(2048), Derivation::max_value());sourcepub fn checked_add(self, rhs: u32) -> Option<Self>
 
pub fn checked_add(self, rhs: u32) -> Option<Self>
checked integer addition. Computes self + rhs, returning None if overflow
would occurred.
Examples
Basic usage:
assert_eq!(Derivation::new(100).checked_add(1), Some(Derivation::new(101)));
assert_eq!(Derivation::max_value().checked_add(2048), None);sourcepub const fn wrapping_add(self, rhs: u32) -> Self
 
pub const fn wrapping_add(self, rhs: u32) -> Self
Wrapping (modular) addition. Computes self + rhs, wrapping around the boundary
of the type.
Examples
Basic usage:
assert_eq!(Derivation::new(100).wrapping_add(1), Derivation::new(101));
assert_eq!(Derivation::max_value().wrapping_add(1), Derivation::new(0));fn saturating_sub(self, rhs: u32) -> Self
Methods from Deref<Target = u32>§
pub const MIN: u32 = 0u32
pub const MAX: u32 = 4_294_967_295u32
pub const BITS: u32 = 32u32
Trait Implementations§
source§impl Clone for Derivation
 
impl Clone for Derivation
source§fn clone(&self) -> Derivation
 
fn clone(&self) -> Derivation
1.0.0 · source§fn clone_from(&mut self, source: &Self)
 
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl Debug for Derivation
 
impl Debug for Derivation
source§impl Default for Derivation
 
impl Default for Derivation
source§fn default() -> Derivation
 
fn default() -> Derivation
source§impl Deref for Derivation
 
impl Deref for Derivation
source§impl Display for Derivation
 
impl Display for Derivation
source§impl From<Derivation> for u32
 
impl From<Derivation> for u32
source§fn from(d: Derivation) -> Self
 
fn from(d: Derivation) -> Self
source§impl From<HardDerivation> for Derivation
 
impl From<HardDerivation> for Derivation
source§fn from(d: HardDerivation) -> Self
 
fn from(d: HardDerivation) -> Self
source§impl From<SoftDerivation> for Derivation
 
impl From<SoftDerivation> for Derivation
source§fn from(d: SoftDerivation) -> Self
 
fn from(d: SoftDerivation) -> Self
source§impl From<u32> for Derivation
 
impl From<u32> for Derivation
source§fn from(v: u32) -> Derivation
 
fn from(v: u32) -> Derivation
source§impl FromIterator<Derivation> for DerivationPath<AnyScheme>
 
impl FromIterator<Derivation> for DerivationPath<AnyScheme>
source§fn from_iter<T: IntoIterator<Item = Derivation>>(iter: T) -> Self
 
fn from_iter<T: IntoIterator<Item = Derivation>>(iter: T) -> Self
source§impl FromStr for Derivation
 
impl FromStr for Derivation
source§impl Hash for Derivation
 
impl Hash for Derivation
source§impl Ord for Derivation
 
impl Ord for Derivation
source§fn cmp(&self, other: &Derivation) -> Ordering
 
fn cmp(&self, other: &Derivation) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
    Self: Sized,
 
fn max(self, other: Self) -> Selfwhere Self: Sized,
source§impl PartialEq<Derivation> for Derivation
 
impl PartialEq<Derivation> for Derivation
source§fn eq(&self, other: &Derivation) -> bool
 
fn eq(&self, other: &Derivation) -> bool
self and other values to be equal, and is used
by ==.source§impl PartialOrd<Derivation> for Derivation
 
impl PartialOrd<Derivation> for Derivation
source§fn partial_cmp(&self, other: &Derivation) -> Option<Ordering>
 
fn partial_cmp(&self, other: &Derivation) -> Option<Ordering>
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 more