pub struct Token { /* private fields */ }Expand description
Represents a token generated by Totp.
This can be thought of as a string with a few notable difference:
- It is only stack allocated
- Comparison is done in constant time regardless of the number of digits in the token
- Formatting is lazily evaluated
Since it implements Display, it can be directly
used in formatting just like a string:
let text: String = format!("{}", token);While Token implements Eq, it’s strongly recommended that you rely on
check instead, as that will take skew into account.
Note that while Token is stack-allocated and only contains plain data, it
does not implement Copy.
This is to preserve compatibility with the zeroize feature which will add
a non-trivial Drop implementation.
Trait Implementations§
impl Eq for Token
Auto Trait Implementations§
impl Freeze for Token
impl RefUnwindSafe for Token
impl Send for Token
impl Sync for Token
impl Unpin for Token
impl UnsafeUnpin for Token
impl UnwindSafe for Token
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
Mutably borrows from an owned value. Read more