keyfork/crates/util/keyfork-prompt/examples/test-basic-prompt.rs

27 lines
622 B
Rust
Raw Normal View History

2024-08-11 23:25:25 +00:00
#![allow(missing_docs)]
2024-01-16 02:44:48 +00:00
use keyfork_prompt::{
prompt_validated_wordlist,
validators::{mnemonic, Validator},
2025-01-04 05:30:41 +00:00
default_handler,
};
use keyfork_mnemonic::English;
2024-01-07 04:23:41 +00:00
fn main() -> Result<(), Box<dyn std::error::Error>> {
2025-01-04 05:30:41 +00:00
let mut handler = default_handler().unwrap();
let transport_validator = mnemonic::MnemonicSetValidator {
2025-01-04 05:30:41 +00:00
word_lengths: [24],
};
let mnemonics = prompt_validated_wordlist::<English, _>(
2025-01-04 05:30:41 +00:00
&mut *handler,
"Enter a 24-word mnemonic: ",
3,
&*transport_validator.to_fn(),
)?;
assert_eq!(mnemonics[0].as_bytes().len(), 32);
Ok(())
}