pub struct Decision { /* private fields */ }Expand description
The outcome of evaluating one check.
Allowed outcomes report quota remaining after the check and the
backend-reported time until the anchored window resets. Denied outcomes
carry a Denial.
Implementations§
Source§impl Decision
impl Decision
Sourcepub const fn allowed(limit: u64, remaining: u64, reset_after: Duration) -> Self
pub const fn allowed(limit: u64, remaining: u64, reset_after: Duration) -> Self
Constructs an allowed decision.
Storage backends should pass the remaining quota after consuming the
check’s cost. This low-level constructor trusts the backend to ensure
remaining <= limit.
Sourcepub const fn is_allowed(&self) -> bool
pub const fn is_allowed(&self) -> bool
Returns whether the check was allowed.
Sourcepub const fn limit(&self) -> Option<u64>
pub const fn limit(&self) -> Option<u64>
Returns the configured limit when it is meaningful for this outcome.
Allowed decisions and quota denials have a limit. Storage-capacity denials do not.
Sourcepub const fn remaining(&self) -> Option<u64>
pub const fn remaining(&self) -> Option<u64>
Returns the quota remaining after an allowed check.
Sourcepub const fn reset_after(&self) -> Option<Duration>
pub const fn reset_after(&self) -> Option<Duration>
Returns the backend-reported time until an allowed check’s anchored window resets.
Sourcepub const fn retry_after(&self) -> Option<Duration>
pub const fn retry_after(&self) -> Option<Duration>
Returns the backend-reported duration after which a denied check may retry.
Sourcepub const fn retry_after_seconds(&self) -> Option<u64>
pub const fn retry_after_seconds(&self) -> Option<u64>
Returns a whole-second Retry-After value rounded up, if known.