pub enum Kind {
Totp,
Hotp,
Steam,
}Expand description
What a stored seed is, which decides what “the current code” means for it.
The three differ in where the counter comes from, not in the arithmetic:
Totp divides the clock by the period, Steam does the same and renders the
result in base 26, and Hotp has no clock at all and uses a number the vault
stores and the user advances.
Phase 22 refused the last two by name. That refusal was right while nothing
could store a counter — an Hotp entry with nowhere to keep its position
shows a code that never changes and never works. Phase 22.2 gives it
somewhere, so the refusal became a limitation instead of a safeguard.
Variants§
Totp
Time-based, RFC 6238. What an entry with no stored kind means.
Hotp
Counter-based, RFC 4226. The counter lives on the entry.
Steam
Time-based like Totp, rendered in Steam’s five-character alphabet.
Implementations§
Source§impl Kind
impl Kind
Sourcepub fn as_str(self) -> &'static str
pub fn as_str(self) -> &'static str
The spelling stored on the entry and used in an otpauth:// path.
Sourcepub fn parse(raw: &str) -> Option<Self>
pub fn parse(raw: &str) -> Option<Self>
Reads that spelling, case-insensitively. None for anything else.
Sourcepub fn is_time_based(self) -> bool
pub fn is_time_based(self) -> bool
True when the code advances on its own, so a countdown means something.
The UI asks this rather than comparing against Kind::Hotp: a card with
no clock must draw no countdown ring, and a card that draws one whose
number never moves is worse than one that draws none.