Struct otp2::Otp

source ·
pub struct Otp<G: ToBytes> { /* private fields */ }
Expand description

One-time passcodes.

See Hotp and Totp.

Implementations§

source§

impl Otp<Counter>

source

pub fn new(key: String, initial_count: u64, length: u32) -> Self

Get a HOTP generator with the given key, initial count, and which generates passcodes of length.

source§

impl Otp<Time>

source

pub fn new(key: String, t0: Instant, window: u64, length: u32) -> Self

Get a TOTP generator.

Repeated calls to Self::get will return the same passcode when in the same window.

source

pub fn new_with_now( key: String, t0: Instant, step: u64, digits: u32, now: Box<dyn Fn() -> Instant> ) -> Self

Get a TOTP generator with a custom function to provide the “now” value.

See Self::new.

source§

impl<G: ToBytes> Otp<G>

source

pub fn get(&mut self) -> OtpResult<u32>

Generate a one-time passcode

Auto Trait Implementations§

§

impl<G> RefUnwindSafe for Otp<G>where G: RefUnwindSafe,

§

impl<G> Send for Otp<G>where G: Send,

§

impl<G> Sync for Otp<G>where G: Sync,

§

impl<G> Unpin for Otp<G>where G: Unpin,

§

impl<G> UnwindSafe for Otp<G>where G: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> ArchivePointee for T

§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<F, W, T, D> Deserialize<With<T, W>, D> for Fwhere W: DeserializeWith<F, T, D>, D: Fallible + ?Sized, F: ?Sized,

§

fn deserialize( &self, deserializer: &mut D ) -> Result<With<T, W>, <D as Fallible>::Error>

Deserializes using the given deserializer
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointee for T

§

type Metadata = ()

The type for metadata in pointers and references to Self.
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.