pub struct Hotp<'h> {
pub base: Base<'h>,
pub counter: Counter,
}
Expand description
Represents HOTP configuration.
Fields§
§base: Base<'h>
The base configuration.
counter: Counter
The counter used to generate codes.
Implementations§
Source§impl<'h> Hotp<'h>
impl<'h> Hotp<'h>
Sourcepub fn builder() -> HotpBuilder<'h>
pub fn builder() -> HotpBuilder<'h>
Create an instance of Hotp
using the builder syntax
Source§impl Hotp<'_>
impl Hotp<'_>
Sourcepub fn try_increment(&mut self) -> bool
pub fn try_increment(&mut self) -> bool
Tries to increment the counter, returning bool
indicating success.
Sourcepub fn increment(&mut self)
pub fn increment(&mut self)
Increments the counter, panicking on overflows.
§Panics
This method will panic if the counter overflows.
Sourcepub fn generate_string(&self) -> String
pub fn generate_string(&self) -> String
Generates the string code for the current counter value.
Sourcepub fn verify_string<S: AsRef<str>>(&self, code: S) -> bool
pub fn verify_string<S: AsRef<str>>(&self, code: S) -> bool
Verifies the string code for the current counter value.
Trait Implementations§
Source§impl<'de, 'h> Deserialize<'de> for Hotp<'h>
impl<'de, 'h> Deserialize<'de> for Hotp<'h>
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>,
Deserialize this value from the given Serde deserializer. Read more
impl<'h> Eq for Hotp<'h>
impl<'h> StructuralPartialEq for Hotp<'h>
Auto Trait Implementations§
impl<'h> Freeze for Hotp<'h>
impl<'h> RefUnwindSafe for Hotp<'h>
impl<'h> Send for Hotp<'h>
impl<'h> Sync for Hotp<'h>
impl<'h> Unpin for Hotp<'h>
impl<'h> UnwindSafe for Hotp<'h>
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