pub struct Totp<'t> {
pub base: Base<'t>,
pub skew: Skew,
pub period: Period,
}
Expand description
Represents TOTP configurations.
Fields§
§base: Base<'t>
The base configuration.
skew: Skew
The skew to apply.
period: Period
The period to use.
Implementations§
Source§impl<'t> Totp<'t>
impl<'t> Totp<'t>
Sourcepub fn builder() -> TotpBuilder<'t>
pub fn builder() -> TotpBuilder<'t>
Create an instance of Totp
using the builder syntax
Source§impl Totp<'_>
impl Totp<'_>
Sourcepub const fn input_at(&self, time: u64) -> u64
pub const fn input_at(&self, time: u64) -> u64
Returns the input value corresponding to the given time.
Sourcepub const fn next_period_at(&self, time: u64) -> u64
pub const fn next_period_at(&self, time: u64) -> u64
Returns the time corresponding to the next period from the given time.
Sourcepub fn try_next_period(&self) -> Result<u64, Error>
pub fn try_next_period(&self) -> Result<u64, Error>
Tries to return the time corresponding to the next period from the current time.
§Errors
Returns time::Error
if the system time is before the epoch.
Sourcepub fn next_period(&self) -> u64
pub fn next_period(&self) -> u64
Returns the time corresponding to the next period from the current time.
§Panics
Panics if the system time is before the epoch.
Sourcepub const fn time_to_live_at(&self, time: u64) -> u64
pub const fn time_to_live_at(&self, time: u64) -> u64
Returns the time to live of the code for the given time.
Sourcepub fn try_time_to_live(&self) -> Result<u64, Error>
pub fn try_time_to_live(&self) -> Result<u64, Error>
Tries to return the time to live of the code for the current time.
§Errors
Returns time::Error
if the system time is before the epoch.
Sourcepub fn time_to_live(&self) -> u64
pub fn time_to_live(&self) -> u64
Returns the time to live of the code for the current time.
§Panics
Panics if the system time is before the epoch.
Sourcepub fn generate_at(&self, time: u64) -> u32
pub fn generate_at(&self, time: u64) -> u32
Generates the code for the given time.
Sourcepub fn generate_string_at(&self, time: u64) -> String
pub fn generate_string_at(&self, time: u64) -> String
Generates the string code for the given time.
Sourcepub fn try_generate(&self) -> Result<u32, Error>
pub fn try_generate(&self) -> Result<u32, Error>
Tries to generate the code for the current time.
§Errors
Returns time::Error
if the system time is before the epoch.
Sourcepub fn try_generate_string(&self) -> Result<String, Error>
pub fn try_generate_string(&self) -> Result<String, Error>
Tries to generate the string code for the current time.
§Errors
Returns time::Error
if the system time is before the epoch.
Sourcepub fn generate_string(&self) -> String
pub fn generate_string(&self) -> String
Generates the string code for the current time.
§Panics
Panics if the system time is before the epoch.
Sourcepub fn verify_exact_at(&self, time: u64, code: u32) -> bool
pub fn verify_exact_at(&self, time: u64, code: u32) -> bool
Verifies the given code for the given time.
Sourcepub fn verify_string_exact_at<S: AsRef<str>>(&self, time: u64, code: S) -> bool
pub fn verify_string_exact_at<S: AsRef<str>>(&self, time: u64, code: S) -> bool
Verifies the given string code for the given time.
Sourcepub fn try_verify_exact(&self, code: u32) -> Result<bool, Error>
pub fn try_verify_exact(&self, code: u32) -> Result<bool, Error>
Tries to verify the given code for the current time exactly.
§Errors
Returns time::Error
if the system time is before the epoch.
Sourcepub fn verify_exact(&self, code: u32) -> bool
pub fn verify_exact(&self, code: u32) -> bool
Verifies the given code for the current time exactly.
§Panics
Panics if the system time is before the epoch.
Sourcepub fn try_verify_string_exact<S: AsRef<str>>(
&self,
code: S,
) -> Result<bool, Error>
pub fn try_verify_string_exact<S: AsRef<str>>( &self, code: S, ) -> Result<bool, Error>
Tries to verify the given string code for the current time exactly.
§Errors
Returns time::Error
if the system time is before the epoch.
Sourcepub fn verify_string_exact<S: AsRef<str>>(&self, code: S) -> bool
pub fn verify_string_exact<S: AsRef<str>>(&self, code: S) -> bool
Verifies the given string code for the current time exactly.
§Panics
Panics if the system time is before the epoch.
Sourcepub fn verify_at(&self, time: u64, code: u32) -> bool
pub fn verify_at(&self, time: u64, code: u32) -> bool
Verifies the given code for the given time, accounting for skews.
Sourcepub fn verify_string_at<S: AsRef<str>>(&self, time: u64, code: S) -> bool
pub fn verify_string_at<S: AsRef<str>>(&self, time: u64, code: S) -> bool
Verifies the given string code for the given time, accounting for skews.
Sourcepub fn try_verify(&self, code: u32) -> Result<bool, Error>
pub fn try_verify(&self, code: u32) -> Result<bool, Error>
Tries to verify the given code for the current time, accounting for skews.
§Errors
Returns time::Error
if the system time is before the epoch.
Sourcepub fn verify(&self, code: u32) -> bool
pub fn verify(&self, code: u32) -> bool
Verifies the given code for the current time, accounting for skews.
§Panics
Panics if the system time is before the epoch.
Sourcepub fn try_verify_string<S: AsRef<str>>(&self, code: S) -> Result<bool, Error>
pub fn try_verify_string<S: AsRef<str>>(&self, code: S) -> Result<bool, Error>
Tries to verify the given string code for the current time, accounting for skews.
§Errors
Returns time::Error
if the system time is before the epoch.