bip39_rusty/
types.rs

1use crate::{MAX_WORDS, MIN_WORDS};
2
3
4
5#[derive(Copy, Clone)]
6pub enum MnemonicType {
7    Bits128, // 128 bits of entropy -> 16 bytes (128 bits / 8)
8    Bits256, // 256 bits of entropy -> 32 bytes (256 bits / 8)
9}
10
11impl MnemonicType {
12    pub const fn bytes(&self) -> usize {
13        match self {
14            MnemonicType::Bits128 => 16,
15            MnemonicType::Bits256 => 32,
16        }
17    }
18
19    pub const fn bits(&self) -> usize {
20        match self {
21            MnemonicType::Bits128 => 128,
22            MnemonicType::Bits256 => 256,
23        }
24    }
25
26    pub const fn words_count(&self) -> usize {
27        match self {
28            MnemonicType::Bits128 => MIN_WORDS,
29            MnemonicType::Bits256 => MAX_WORDS,
30        }
31    }
32}