pub struct CustomHDPath(pub Vec<PathValue>);
Expand description

A custom HD Path, that can be any length and contain any Hardened and non-Hardened values in any order. Direct implementation for BIP-32

If you need just standard type of HD Path like m/44'/0'/0'/0/0 use StandardHDPath instead.

Usage

Parse string

use hdpath::CustomHDPath;

let hdpath = CustomHDPath::try_from("m/1'/2'/3/4/5'/6'/7").unwrap();
let hdpath = CustomHDPath::try_from("m/44'/0'/1'/0/0").unwrap();
//also support uppercase notation
let hdpath = CustomHDPath::try_from("M/44H/0H/1H/0/0").unwrap();

Direct create

use hdpath::{CustomHDPath, PathValue};

let hdpath = CustomHDPath::try_new(vec![
   PathValue::hardened(44), PathValue::hardened(0), PathValue::hardened(1),
   PathValue::normal(0), PathValue::normal(0)
]).unwrap();

Tuple Fields

0: Vec<PathValue>

Implementations

Create a new HD Path.

Returns error only if provided vector is too large, i.e. more than 255 elements (since BIP-32 says about ability to encode depth in a single byte).

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

Converts to this type from the input type.

Converts to this type from the input type.

The associated error which can be returned from parsing.

Parses a string s to return a value of this type. Read more

Size of the HD Path

Get element as the specified position. The implementation must return Some<PathValue> for all values up to len(). And return None if the position if out of bounds. Read more

Encode as bytes, where first byte is number of elements in path (always 5 for StandardHDPath) following by 4-byte BE values Read more

Get parent HD Path. Return None if the current path is empty (i.e. already at the top) Read more

Convert current to CustomHDPath structure Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.