pub trait XKeyEncoder {
// Required methods
fn write_xpub<W, K>(writer: &mut W, key: &K) -> Result<usize, Bip32Error>
where W: Write,
K: AsRef<XPub>;
fn write_xpriv<W, K>(writer: &mut W, key: &K) -> Result<usize, Bip32Error>
where W: Write,
K: AsRef<XPriv>;
fn read_xpriv<R>(reader: &mut R) -> Result<XPriv, Bip32Error>
where R: Read;
fn read_xpub<R>(reader: &mut R) -> Result<XPub, Bip32Error>
where R: Read;
// Provided methods
fn xpriv_to_base58<K>(k: &K) -> Result<String, Bip32Error>
where K: AsRef<XPriv> { ... }
fn xpub_to_base58<K>(k: &K) -> Result<String, Bip32Error>
where K: AsRef<XPub> { ... }
fn xpriv_from_base58(s: &str) -> Result<XPriv, Bip32Error> { ... }
fn xpub_from_base58(s: &str) -> Result<XPub, Bip32Error> { ... }
}
Expand description
Bip32/49/84 encoder
Required Methods§
Sourcefn write_xpub<W, K>(writer: &mut W, key: &K) -> Result<usize, Bip32Error>
fn write_xpub<W, K>(writer: &mut W, key: &K) -> Result<usize, Bip32Error>
Serialize the xpub to std::io::Write
Sourcefn write_xpriv<W, K>(writer: &mut W, key: &K) -> Result<usize, Bip32Error>
fn write_xpriv<W, K>(writer: &mut W, key: &K) -> Result<usize, Bip32Error>
Serialize the xpriv to std::io::Write
Sourcefn read_xpriv<R>(reader: &mut R) -> Result<XPriv, Bip32Error>where
R: Read,
fn read_xpriv<R>(reader: &mut R) -> Result<XPriv, Bip32Error>where
R: Read,
Attempt to instantiate an XPriv
from a std::io::Read
use coins_bip32::{Bip32Error, xkeys::XPriv, enc::{XKeyEncoder, MainnetEncoder}};
let xpriv_str = "xprv9s21ZrQH143K3QTDL4LXw2F7HEK3wJUD2nW2nRk4stbPy6cq3jPPqjiChkVvvNKmPGJxWUtg6LnF5kejMRNNU3TGtRBeJgk33yuGBxrMPHi".to_owned();
let xpriv: XPriv = MainnetEncoder::xpriv_from_base58(&xpriv_str)?;
Sourcefn read_xpub<R>(reader: &mut R) -> Result<XPub, Bip32Error>where
R: Read,
fn read_xpub<R>(reader: &mut R) -> Result<XPub, Bip32Error>where
R: Read,
Attempt to instantiate an XPub
from a std::io::Read
use coins_bip32::{Bip32Error, xkeys::XPub, enc::{XKeyEncoder, MainnetEncoder}};
let xpub_str = "xpub68NZiKmJWnxxS6aaHmn81bvJeTESw724CRDs6HbuccFQN9Ku14VQrADWgqbhhTHBaohPX4CjNLf9fq9MYo6oDaPPLPxSb7gwQN3ih19Zm4Y".to_owned();
let xpub: XPub = MainnetEncoder::xpub_from_base58(&xpub_str)?;
Provided Methods§
Sourcefn xpriv_to_base58<K>(k: &K) -> Result<String, Bip32Error>
fn xpriv_to_base58<K>(k: &K) -> Result<String, Bip32Error>
Serialize an XPriv to base58
Sourcefn xpub_to_base58<K>(k: &K) -> Result<String, Bip32Error>
fn xpub_to_base58<K>(k: &K) -> Result<String, Bip32Error>
Serialize an XPub to base58
Sourcefn xpriv_from_base58(s: &str) -> Result<XPriv, Bip32Error>
fn xpriv_from_base58(s: &str) -> Result<XPriv, Bip32Error>
Attempt to read an XPriv from a b58check string.
use coins_bip32::{Bip32Error, xkeys::XPriv, enc::{XKeyEncoder, MainnetEncoder}};
let xpriv_str = "xprv9s21ZrQH143K3QTDL4LXw2F7HEK3wJUD2nW2nRk4stbPy6cq3jPPqjiChkVvvNKmPGJxWUtg6LnF5kejMRNNU3TGtRBeJgk33yuGBxrMPHi".to_owned();
let xpriv: XPriv = MainnetEncoder::xpriv_from_base58(&xpriv_str)?;
Sourcefn xpub_from_base58(s: &str) -> Result<XPub, Bip32Error>
fn xpub_from_base58(s: &str) -> Result<XPub, Bip32Error>
Attempt to read an XPub from a b58check string
use coins_bip32::{Bip32Error, xkeys::XPub, enc::{XKeyEncoder, MainnetEncoder}};
let xpub_str = "xpub68NZiKmJWnxxS6aaHmn81bvJeTESw724CRDs6HbuccFQN9Ku14VQrADWgqbhhTHBaohPX4CjNLf9fq9MYo6oDaPPLPxSb7gwQN3ih19Zm4Y".to_owned();
let xpub: XPub = MainnetEncoder::xpub_from_base58(&xpub_str)?;
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.