Trait walletd_bitcoin::MnemonicBuilder
pub trait MnemonicBuilder {
type Mnemonic;
type Language;
type MnemonicType;
type ErrorType;
// Required methods
fn new() -> Self;
fn mnemonic_seed(&mut self, seed: &Seed) -> &mut Self;
fn mnemonic_phrase(&mut self, mnemonic_phrase: &str) -> &mut Self;
fn language(&mut self, language: Self::Language) -> &mut Self;
fn passphrase(&mut self, passphrase: &str) -> &mut Self;
fn mnemonic_type(&mut self, mnemonic_type: Self::MnemonicType) -> &mut Self;
fn detect_language(&mut self) -> &mut Self;
fn build(&self) -> Result<Self::Mnemonic, Self::ErrorType>;
fn restore(&self) -> Result<Self::Mnemonic, Self::ErrorType>;
fn generate(&self) -> Result<Self::Mnemonic, Self::ErrorType>;
}
Expand description
Provides a builder pattern for creating a Mnemonic.
Required Associated Types§
type Mnemonic
type Mnemonic
The associated Mnemonic struct
type Language
type Language
The associated Language struct
type MnemonicType
type MnemonicType
The associated MnemonicType struct
type ErrorType
type ErrorType
The type of error that can be returned by the builder
Required Methods§
fn new() -> Self
fn new() -> Self
Creates a new builder struct with default values.
The default values depend on the implementation of the builder.
fn mnemonic_seed(&mut self, seed: &Seed) -> &mut Self
fn mnemonic_seed(&mut self, seed: &Seed) -> &mut Self
Specifies the seed from which the mnemonic struct is recovered.
If a passphrase is specified with the passphrase method, the seed recovered using the restore or build method will be the encrypted version of the seed which takes into account the passphrase value.
fn mnemonic_phrase(&mut self, mnemonic_phrase: &str) -> &mut Self
fn mnemonic_phrase(&mut self, mnemonic_phrase: &str) -> &mut Self
Specifies the mnemonic phrase from which the mnemonic struct is recovered.
fn language(&mut self, language: Self::Language) -> &mut Self
fn language(&mut self, language: Self::Language) -> &mut Self
Specifies the language for the mnemonic phrase, can be used when recovering a mnemonic phrase or generating a new mnemonic phrase.
fn passphrase(&mut self, passphrase: &str) -> &mut Self
fn passphrase(&mut self, passphrase: &str) -> &mut Self
Specifies a passphrase to use to offset/encrypt the seed recovered from the mnemonic phrase.
fn mnemonic_type(&mut self, mnemonic_type: Self::MnemonicType) -> &mut Self
fn mnemonic_type(&mut self, mnemonic_type: Self::MnemonicType) -> &mut Self
Specifies the mnemonic type to use when recovering or generating a mnemonic phrase.
fn detect_language(&mut self) -> &mut Self
fn detect_language(&mut self) -> &mut Self
Sets the specified language to None.
When used with mnemonic_phrase and build or restore, automatically detects the language of the mnemonic phrase and returns an error if the mnemonic phrase is invalid for every mnemonic language wordlist.
fn build(&self) -> Result<Self::Mnemonic, Self::ErrorType>
fn build(&self) -> Result<Self::Mnemonic, Self::ErrorType>
Builds a mnemonic struct given the specifications provided to the builder.
build() can be used in place of generate() or restore() and will emulate the appropriate behavior based on the specifications provided to the builder.
Implementations on Foreign Types§
source§impl MnemonicBuilder for Bip39MnemonicBuilder
impl MnemonicBuilder for Bip39MnemonicBuilder
source§fn new() -> Bip39MnemonicBuilder
fn new() -> Bip39MnemonicBuilder
Creates a new Bip39MnemonicBuilder struct with default values.
source§fn detect_language(&mut self) -> &mut Bip39MnemonicBuilder
fn detect_language(&mut self) -> &mut Bip39MnemonicBuilder
Sets the specified language to None.
Useful for overriding the default English language assumption when using a mnemonic phrase in a non-English language without needing to specify which language the mnemonic phrase is in.
When used with mnemonic_phrase and build or restore, automatically detects the language of the mnemonic phrase and returns an error if the mnemonic phrase is invalid for every mnemonic language wordlist.
source§fn generate(
&self
) -> Result<<Bip39MnemonicBuilder as MnemonicBuilder>::Mnemonic, <Bip39MnemonicBuilder as MnemonicBuilder>::ErrorType>
fn generate( &self ) -> Result<<Bip39MnemonicBuilder as MnemonicBuilder>::Mnemonic, <Bip39MnemonicBuilder as MnemonicBuilder>::ErrorType>
Generate a new mnemonic which follows given specifications
source§fn build(
&self
) -> Result<<Bip39MnemonicBuilder as MnemonicBuilder>::Mnemonic, <Bip39MnemonicBuilder as MnemonicBuilder>::ErrorType>
fn build( &self ) -> Result<<Bip39MnemonicBuilder as MnemonicBuilder>::Mnemonic, <Bip39MnemonicBuilder as MnemonicBuilder>::ErrorType>
Build a mnemonic struct based on the specifications provided