pub struct PhoneCodeStore { /* private fields */ }Implementations§
Source§impl PhoneCodeStore
impl PhoneCodeStore
pub fn new() -> Self
pub fn with_backend(backend: Box<dyn PhoneCodeBackend>) -> Self
Sourcepub fn try_create(&self, phone: &str) -> Result<String, PhoneCodeError>
pub fn try_create(&self, phone: &str) -> Result<String, PhoneCodeError>
Generate + store a 6-digit code, returning it for the caller to send via SMS. Throttled to one request per 30 seconds per phone to make SMS-cost-bombing impractical.
Sourcepub fn try_verify(&self, phone: &str, code: &str) -> Result<(), PhoneCodeError>
pub fn try_verify(&self, phone: &str, code: &str) -> Result<(), PhoneCodeError>
Verify a code. Equalizes timing between “no pending code” and “wrong code” paths by always running a constant-time compare against a dummy value when the lookup misses, so an attacker can’t enumerate which phone numbers have requested codes.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PhoneCodeStore
impl !RefUnwindSafe for PhoneCodeStore
impl Send for PhoneCodeStore
impl Sync for PhoneCodeStore
impl Unpin for PhoneCodeStore
impl UnsafeUnpin for PhoneCodeStore
impl !UnwindSafe for PhoneCodeStore
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