Struct CodeAlphabet
#[non_exhaustive]pub struct CodeAlphabet {
pub chars: String,
pub len: usize,
}Expand description
The characters and length of a short code a person reads and types: a PIN or a device-flow user code.
The crate matches codes exactly over chars: it ignores no case, dash or space. Normalising
what a person typed, and grouping a code for display, is the caller’s. Any alphabet and
length with a meaning is accepted; combinations says how many
codes there are, which is what an attacker’s one guess is against.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.chars: StringThe characters a code is made of, each once.
len: usizeHow many characters a code has.
Implementations§
§impl CodeAlphabet
impl CodeAlphabet
pub fn new(chars: impl Into<String>, len: usize) -> CodeAlphabet
pub fn new(chars: impl Into<String>, len: usize) -> CodeAlphabet
An alphabet of the characters chars, each once, and codes of len of them.
pub fn pin() -> CodeAlphabet
pub fn pin() -> CodeAlphabet
The default PIN alphabet: 0123456789, 6 characters (10^6 codes).
pub fn user_code() -> CodeAlphabet
pub fn user_code() -> CodeAlphabet
The default user-code alphabet of RFC 8628 section 6.1: BCDFGHJKLMNPQRSTVWXZ, 8
characters (about 2.6 × 10^10 codes).
pub fn combinations(&self) -> u128
pub fn combinations(&self) -> u128
How many distinct codes there are, saturating at u128::MAX.
Trait Implementations§
§impl Clone for CodeAlphabet
impl Clone for CodeAlphabet
§fn clone(&self) -> CodeAlphabet
fn clone(&self) -> CodeAlphabet
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more