[−][src]Enum hdwallet::extended_key::key_index::KeyIndex
KeyIndex indicates the key type and index of a child key.
Variants
Normal(u32)
Normal key, index range is from 0 to 2 ** 31 - 1
Hardened(u32)
Hardened key, index range is from 2 ** 31 to 2 ** 32 - 1
Methods
impl KeyIndex
[src]
pub fn raw_index(self) -> u32
[src]
Return raw index value
pub fn normalize_index(self) -> u32
[src]
Return normalize index, it will return index subtract 2 ** 31 for hardended key.
Examples
use hdwallet::KeyIndex; assert_eq!(KeyIndex::Normal(0).normalize_index(), 0); assert_eq!(KeyIndex::Hardened(2_147_483_648).normalize_index(), 0);
pub fn is_valid(self) -> bool
[src]
Check index range.
Examples
use hdwallet::KeyIndex; assert!(KeyIndex::Normal(0).is_valid()); assert!(!KeyIndex::Normal(2_147_483_648).is_valid()); assert!(KeyIndex::Hardened(2_147_483_648).is_valid());
pub fn hardened_from_normalize_index(i: u32) -> Result<KeyIndex, Error>
[src]
Generate Hardened KeyIndex from normalize index value.
Examples
use hdwallet::KeyIndex; // hardended key from zero let hardened_index_zero = KeyIndex::hardened_from_normalize_index(0).unwrap(); assert_eq!(hardened_index_zero, KeyIndex::Hardened(2_147_483_648)); // also allow raw index for convernient let hardened_index_zero = KeyIndex::hardened_from_normalize_index(2_147_483_648).unwrap(); assert_eq!(hardened_index_zero, KeyIndex::Hardened(2_147_483_648));
pub fn from_index(i: u32) -> Result<Self, Error>
[src]
Generate KeyIndex from raw index value.
Examples
use hdwallet::KeyIndex; let normal_key = KeyIndex::from_index(0).unwrap(); assert_eq!(normal_key, KeyIndex::Normal(0)); let hardened_key = KeyIndex::from_index(2_147_483_648).unwrap(); assert_eq!(hardened_key, KeyIndex::Hardened(2_147_483_648));
Trait Implementations
impl Copy for KeyIndex
[src]
impl PartialEq<KeyIndex> for KeyIndex
[src]
impl From<u32> for KeyIndex
[src]
impl Clone for KeyIndex
[src]
fn clone(&self) -> KeyIndex
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Eq for KeyIndex
[src]
impl Debug for KeyIndex
[src]
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,