pub struct Mnemonic { /* private fields */ }Implementations§
Source§impl Mnemonic
impl Mnemonic
Sourcepub fn new(lang: Language, mnemonic_type: MnemonicType) -> Mnemonic
pub fn new(lang: Language, mnemonic_type: MnemonicType) -> Mnemonic
Wrapper for .generator() function, created to handle errors
Examples found in repository?
examples/generate_mnemonics.rs (line 19)
3fn main() {
4 /*
5 Demonstrating the use of the bip39-rusty library to generate a BIP39 mnemonic phrase.
6
7 The `Mnemonic` struct expects:
8 - Language (e.g., Language::English)
9 - MnemonicType (e.g., Bits128 or Bits256)
10
11 Once created, you can use the following getter method:
12 - .mnemonic_phrase() => Returns the generated mnemonic phrase as a Vec<String>.
13
14 Note: If any internal error occurs during mnemonic generation,
15 the library will return a default Mnemonic with 256 bits and Language::English type.
16 */
17
18 // Create a new mnemonic
19 let mnemonic = Mnemonic::new(Language::English, MnemonicType::Bits256);
20
21 // Display the mnemonic phrases
22 println!("Generated Mnemonic Phrase: {:?}", mnemonic.mnemonic_phrase());
23
24 // validate the checksum
25 let validation_result = mnemonic.validate_checksum();
26
27 match validation_result {
28 Ok(_value) => {
29 println!("Its valid")
30 }
31 Err(_e) => {
32 println!("Not valid")
33 }
34 }
35
36}Sourcepub fn validate_checksum(&self) -> Result<bool, MnemonicError>
pub fn validate_checksum(&self) -> Result<bool, MnemonicError>
Examples found in repository?
examples/generate_mnemonics.rs (line 25)
3fn main() {
4 /*
5 Demonstrating the use of the bip39-rusty library to generate a BIP39 mnemonic phrase.
6
7 The `Mnemonic` struct expects:
8 - Language (e.g., Language::English)
9 - MnemonicType (e.g., Bits128 or Bits256)
10
11 Once created, you can use the following getter method:
12 - .mnemonic_phrase() => Returns the generated mnemonic phrase as a Vec<String>.
13
14 Note: If any internal error occurs during mnemonic generation,
15 the library will return a default Mnemonic with 256 bits and Language::English type.
16 */
17
18 // Create a new mnemonic
19 let mnemonic = Mnemonic::new(Language::English, MnemonicType::Bits256);
20
21 // Display the mnemonic phrases
22 println!("Generated Mnemonic Phrase: {:?}", mnemonic.mnemonic_phrase());
23
24 // validate the checksum
25 let validation_result = mnemonic.validate_checksum();
26
27 match validation_result {
28 Ok(_value) => {
29 println!("Its valid")
30 }
31 Err(_e) => {
32 println!("Not valid")
33 }
34 }
35
36}Sourcepub fn mnemonic_phrase(&self) -> &Vec<String>
pub fn mnemonic_phrase(&self) -> &Vec<String>
Getter for the mnemonic phrase.
Examples found in repository?
examples/generate_mnemonics.rs (line 22)
3fn main() {
4 /*
5 Demonstrating the use of the bip39-rusty library to generate a BIP39 mnemonic phrase.
6
7 The `Mnemonic` struct expects:
8 - Language (e.g., Language::English)
9 - MnemonicType (e.g., Bits128 or Bits256)
10
11 Once created, you can use the following getter method:
12 - .mnemonic_phrase() => Returns the generated mnemonic phrase as a Vec<String>.
13
14 Note: If any internal error occurs during mnemonic generation,
15 the library will return a default Mnemonic with 256 bits and Language::English type.
16 */
17
18 // Create a new mnemonic
19 let mnemonic = Mnemonic::new(Language::English, MnemonicType::Bits256);
20
21 // Display the mnemonic phrases
22 println!("Generated Mnemonic Phrase: {:?}", mnemonic.mnemonic_phrase());
23
24 // validate the checksum
25 let validation_result = mnemonic.validate_checksum();
26
27 match validation_result {
28 Ok(_value) => {
29 println!("Its valid")
30 }
31 Err(_e) => {
32 println!("Not valid")
33 }
34 }
35
36}Auto Trait Implementations§
impl Freeze for Mnemonic
impl RefUnwindSafe for Mnemonic
impl Send for Mnemonic
impl Sync for Mnemonic
impl Unpin for Mnemonic
impl UnwindSafe for Mnemonic
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more