pub struct LoginThrottle { /* private fields */ }Implementations§
Source§impl LoginThrottle
impl LoginThrottle
Sourcepub fn new(max_attempts: u32, window: Duration) -> Self
pub fn new(max_attempts: u32, window: Duration) -> Self
Allows max_attempts password checks per user within window. A
successful check resets the user’s count. Zero disables throttling.
Sourcepub async fn try_attempt(&self, user: &str) -> bool
pub async fn try_attempt(&self, user: &str) -> bool
Registers a password check for user before it runs. Returns false
if the user exhausted the allowed attempts in the current window, in
which case the password must not be checked at all.
Counting before the check (instead of after a failure) keeps parallel requests from exceeding the limit.
Auto Trait Implementations§
impl !RefUnwindSafe for LoginThrottle
impl !UnwindSafe for LoginThrottle
impl Forget for LoginThrottle
impl Freeze for LoginThrottle
impl Move for LoginThrottle
impl Send for LoginThrottle
impl Sync for LoginThrottle
impl Unpin for LoginThrottle
impl UnsafeUnpin for LoginThrottle
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more