[−][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 Clone for KeyIndex
[src]
impl Copy for KeyIndex
[src]
impl Debug for KeyIndex
[src]
impl Eq for KeyIndex
[src]
impl From<u32> for KeyIndex
[src]
impl PartialEq<KeyIndex> for KeyIndex
[src]
impl StructuralEq for KeyIndex
[src]
impl StructuralPartialEq for KeyIndex
[src]
Auto Trait Implementations
impl RefUnwindSafe for KeyIndex
impl Send for KeyIndex
impl Sync for KeyIndex
impl Unpin for KeyIndex
impl UnwindSafe for KeyIndex
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> 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, U> TryInto<U> 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<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,