Struct slip132::KeyVersion
source · [−]pub struct KeyVersion(_);
Expand description
Structure holding 4 version bytes with magical numbers representing
different versions of extended public and private keys according to BIP-32.
Key version stores raw bytes without their check, interpretation or
verification; for these purposes special helpers structures implementing
VersionResolver
are used.
Implementations
sourceimpl KeyVersion
impl KeyVersion
sourcepub fn is_pub<R: VersionResolver>(&self) -> Option<bool>
pub fn is_pub<R: VersionResolver>(&self) -> Option<bool>
Detects whether provided version corresponds to an extended public key.
Returns None
if the version is not recognized/unknown to the resolver.
sourcepub fn is_prv<R: VersionResolver>(&self) -> Option<bool>
pub fn is_prv<R: VersionResolver>(&self) -> Option<bool>
Detects whether provided version corresponds to an extended private key.
Returns None
if the version is not recognized/unknown to the resolver.
sourcepub fn network<R: VersionResolver>(&self) -> Option<R::Network>
pub fn network<R: VersionResolver>(&self) -> Option<R::Network>
Detects network used by the provided key version bytes.
Returns None
if the version is not recognized/unknown to the resolver.
sourcepub fn application<R: VersionResolver>(&self) -> Option<R::Application>
pub fn application<R: VersionResolver>(&self) -> Option<R::Application>
Detects application scope defined by the provided key version bytes.
Application scope is a types of scriptPubkey descriptors in which given
extended public/private keys can be used.
Returns None
if the version is not recognized/unknown to the resolver.
sourcepub fn derivation_path<R: VersionResolver>(
&self,
account: Option<ChildNumber>
) -> Option<DerivationPath>
pub fn derivation_path<R: VersionResolver>(
&self,
account: Option<ChildNumber>
) -> Option<DerivationPath>
Returns BIP 32 derivation path for the provided key version.
Returns None
if the version is not recognized/unknown to the resolver.
sourcepub fn try_to_pub<R: VersionResolver>(&self) -> Option<KeyVersion>
pub fn try_to_pub<R: VersionResolver>(&self) -> Option<KeyVersion>
Converts version into version corresponding to an extended public key.
Returns None
if the resolver does not know how to perform conversion.
sourcepub fn try_to_prv<R: VersionResolver>(&self) -> Option<KeyVersion>
pub fn try_to_prv<R: VersionResolver>(&self) -> Option<KeyVersion>
Converts version into version corresponding to an extended private key.
Returns None
if the resolver does not know how to perform conversion.
sourceimpl KeyVersion
impl KeyVersion
sourcepub fn from_slice(version_slice: &[u8]) -> Option<KeyVersion>
pub fn from_slice(version_slice: &[u8]) -> Option<KeyVersion>
Tries to construct KeyVersion
object from a byte slice. If byte
slice length is not equal to 4, returns None
sourcepub fn from_xkey_str(key: &str) -> Result<KeyVersion, Error>
pub fn from_xkey_str(key: &str) -> Result<KeyVersion, Error>
Constructs KeyVersion
from a Base58-encoded extended key string.
Panics
If the string does not contain at least 5 characters.
sourcepub fn from_bytes(version_bytes: [u8; 4]) -> KeyVersion
pub fn from_bytes(version_bytes: [u8; 4]) -> KeyVersion
Constructs KeyVersion
from a fixed 4 bytes values
sourcepub fn from_u32(version: u32) -> KeyVersion
pub fn from_u32(version: u32) -> KeyVersion
Constructs KeyVersion
from a u32
-representation of the version
bytes (the representation must be in bing endian format)
sourcepub fn to_u32(&self) -> u32
pub fn to_u32(&self) -> u32
Converts version bytes into u32
representation in big endian format
sourcepub fn as_slice(&self) -> &[u8]ⓘNotable traits for &'_ mut [u8]impl<'_> Write for &'_ mut [u8]impl<'_> Read for &'_ [u8]
pub fn as_slice(&self) -> &[u8]ⓘNotable traits for &'_ mut [u8]impl<'_> Write for &'_ mut [u8]impl<'_> Read for &'_ [u8]
Returns slice representing internal version bytes
sourcepub fn into_bytes(self) -> [u8; 4]
pub fn into_bytes(self) -> [u8; 4]
Converts into 4-byte array containing version byte values
Trait Implementations
sourceimpl Clone for KeyVersion
impl Clone for KeyVersion
sourcefn clone(&self) -> KeyVersion
fn clone(&self) -> KeyVersion
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for KeyVersion
impl Debug for KeyVersion
sourceimpl Hash for KeyVersion
impl Hash for KeyVersion
sourceimpl Ord for KeyVersion
impl Ord for KeyVersion
sourceimpl PartialEq<KeyVersion> for KeyVersion
impl PartialEq<KeyVersion> for KeyVersion
sourcefn eq(&self, other: &KeyVersion) -> bool
fn eq(&self, other: &KeyVersion) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &KeyVersion) -> bool
fn ne(&self, other: &KeyVersion) -> bool
This method tests for !=
.
sourceimpl PartialOrd<KeyVersion> for KeyVersion
impl PartialOrd<KeyVersion> for KeyVersion
sourcefn partial_cmp(&self, other: &KeyVersion) -> Option<Ordering>
fn partial_cmp(&self, other: &KeyVersion) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl Copy for KeyVersion
impl Eq for KeyVersion
impl StructuralEq for KeyVersion
impl StructuralPartialEq for KeyVersion
Auto Trait Implementations
impl RefUnwindSafe for KeyVersion
impl Send for KeyVersion
impl Sync for KeyVersion
impl Unpin for KeyVersion
impl UnwindSafe for KeyVersion
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more