pub struct DerivationPath(/* private fields */);Expand description
A Bip32 derivation path
Implementations§
Source§impl DerivationPath
impl DerivationPath
Sourcepub fn last(&self) -> Option<&u32>
pub fn last(&self) -> Option<&u32>
Return the last index in the path. None if the path is the root.
Sourcepub fn derivation_string(&self) -> String
pub fn derivation_string(&self) -> String
Converts the path to a standard bip32 string. e.g "m/44'/0'/0/32".
Sourcepub fn starts_with(&self, other: &DerivationPath) -> bool
pub fn starts_with(&self, other: &DerivationPath) -> bool
true if other is a prefix of self
Sourcepub fn without_prefix(&self, prefix: &DerivationPath) -> Option<DerivationPath>
pub fn without_prefix(&self, prefix: &DerivationPath) -> Option<DerivationPath>
Remove a prefix from a derivation. Return a new DerivationPath without the prefix. This is useful for determining the path to rech some descendant from some ancestor.
Sourcepub fn last_hardened(&self) -> (usize, Option<u32>)
pub fn last_hardened(&self) -> (usize, Option<u32>)
Convenience function for finding the last hardened derivation in a path. Returns the index and the element. If there is no hardened derivation, it will return (0, None).
Sourcepub fn resized(&self, size: usize, pad_with: u32) -> DerivationPath
pub fn resized(&self, size: usize, pad_with: u32) -> DerivationPath
Return a clone with a resized path. If the new size is shorter, this truncates it. If the new path is longer, we pad with the second argument.
Sourcepub fn extended(&self, idx: u32) -> DerivationPath
pub fn extended(&self, idx: u32) -> DerivationPath
Append an additional derivation to the end, return a clone
Trait Implementations§
Source§impl Clone for DerivationPath
impl Clone for DerivationPath
Source§fn clone(&self) -> DerivationPath
fn clone(&self) -> DerivationPath
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for DerivationPath
impl Debug for DerivationPath
Source§impl Default for DerivationPath
impl Default for DerivationPath
Source§fn default() -> DerivationPath
fn default() -> DerivationPath
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for DerivationPath
impl<'de> Deserialize<'de> for DerivationPath
Source§fn deserialize<D>(
deserializer: D,
) -> Result<DerivationPath, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<DerivationPath, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl From<&[u32]> for DerivationPath
impl From<&[u32]> for DerivationPath
Source§fn from(v: &[u32]) -> DerivationPath
fn from(v: &[u32]) -> DerivationPath
Converts to this type from the input type.
Source§impl From<&DerivationPath> for DerivationPath
impl From<&DerivationPath> for DerivationPath
Source§fn from(v: &DerivationPath) -> DerivationPath
fn from(v: &DerivationPath) -> DerivationPath
Converts to this type from the input type.
Source§impl FromIterator<u32> for DerivationPath
impl FromIterator<u32> for DerivationPath
Source§fn from_iter<T>(iter: T) -> DerivationPathwhere
T: IntoIterator<Item = u32>,
fn from_iter<T>(iter: T) -> DerivationPathwhere
T: IntoIterator<Item = u32>,
Creates a value from an iterator. Read more
Source§impl FromStr for DerivationPath
impl FromStr for DerivationPath
Source§type Err = Bip32Error
type Err = Bip32Error
The associated error which can be returned from parsing.
Source§fn from_str(s: &str) -> Result<DerivationPath, <DerivationPath as FromStr>::Err>
fn from_str(s: &str) -> Result<DerivationPath, <DerivationPath as FromStr>::Err>
Parses a string
s to return a value of this type. Read moreSource§impl PartialEq for DerivationPath
impl PartialEq for DerivationPath
Source§impl Serialize for DerivationPath
impl Serialize for DerivationPath
Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
Source§impl TryFrom<&str> for DerivationPath
impl TryFrom<&str> for DerivationPath
Source§type Error = Bip32Error
type Error = Bip32Error
The type returned in the event of a conversion error.
Source§fn try_from(
v: &str,
) -> Result<DerivationPath, <DerivationPath as TryFrom<&str>>::Error>
fn try_from( v: &str, ) -> Result<DerivationPath, <DerivationPath as TryFrom<&str>>::Error>
Performs the conversion.
Source§impl TryFrom<u32> for DerivationPath
impl TryFrom<u32> for DerivationPath
Source§type Error = Bip32Error
type Error = Bip32Error
The type returned in the event of a conversion error.
Source§fn try_from(
v: u32,
) -> Result<DerivationPath, <DerivationPath as TryFrom<u32>>::Error>
fn try_from( v: u32, ) -> Result<DerivationPath, <DerivationPath as TryFrom<u32>>::Error>
Performs the conversion.
impl Eq for DerivationPath
impl StructuralPartialEq for DerivationPath
Auto Trait Implementations§
impl Freeze for DerivationPath
impl RefUnwindSafe for DerivationPath
impl Send for DerivationPath
impl Sync for DerivationPath
impl Unpin for DerivationPath
impl UnwindSafe for DerivationPath
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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
Compare self to
key and return true if they are equal.