pub struct StandardHDPath { /* private fields */ }
Expand description

Standard HD Path for BIP-44, BIP-49, BIP-84 and similar. For path as m/purpose'/coin_type'/account'/change/address_index, like m/44'/0'/0'/0/0.

Create new

use hdpath::{StandardHDPath, Purpose};

//creates path m/84'/0'/0'/0/0
let hdpath = StandardHDPath::new(Purpose::Witness, 0, 0, 0, 0);

Parse string

use hdpath::{StandardHDPath, Purpose};

//creates path m/84'/0'/0'/0/0
let hdpath = StandardHDPath::from_str("m/84'/0'/0'/0/0").unwrap();

Implementations

Create a standard HD Path. Panics if any of the values is incorrect

use hdpath::{StandardHDPath, Purpose};

let hdpath =  StandardHDPath::new(Purpose::Witness, 0, 2, 0, 0);

Try to create a standard HD Path. Return error (field_name, invalid_value) if a field has an incorrect value.

use hdpath::{StandardHDPath, Purpose};


let index = 0x80000100; //received from unreliable source
match StandardHDPath::try_new(Purpose::Witness, 0, 2, 0, index) {
    Ok(hdpath) => { }
    Err(err) => println!("Invalid value {} = {}", err.0, err.1)
}

Decode from bytes, where first byte is number of elements in path (always 5 for StandardHDPath) following by 4-byte BE values

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

Returns the “default value” for a type. 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.

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 returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

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

This method tests for !=.

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. 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.

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.