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.
Trait Implementations§
impl Copy for Kind
Source§impl<'de> Deserialize<'de> for Kind
impl<'de> Deserialize<'de> for Kind
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Kind
impl StructuralPartialEq for Kind
Auto Trait Implementations§
impl Freeze for Kind
impl RefUnwindSafe for Kind
impl Send for Kind
impl Sync for Kind
impl Unpin for Kind
impl UnsafeUnpin for Kind
impl UnwindSafe for Kind
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.