pub trait RateLimitPolicy:
Debug
+ Send
+ Sync {
// Required methods
fn id(&self) -> &PolicyId;
fn scope(&self) -> &ScopeId;
fn quota(&self) -> u64;
fn quota_period(&self) -> Duration;
fn capacity(&self) -> u64;
fn fingerprint(&self) -> PolicyFingerprint;
fn quota_mode(&self) -> QuotaMode;
}Expand description
Backend-independent policy metadata required to construct a check.
Storage backends remain free to support one specific policy algorithm by
choosing it as crate::Limiter::Policy. Application adapters can be
generic over this trait without assuming fixed-window behavior.
Required Methods§
Sourcefn quota(&self) -> u64
fn quota(&self) -> u64
Returns the quota replenished during Self::quota_period.
Sourcefn quota_period(&self) -> Duration
fn quota_period(&self) -> Duration
Returns the period during which Self::quota is replenished.
Sourcefn capacity(&self) -> u64
fn capacity(&self) -> u64
Returns the largest single cost and maximum immediately available allowance supported by this policy.
Sourcefn fingerprint(&self) -> PolicyFingerprint
fn fingerprint(&self) -> PolicyFingerprint
Returns the deterministic storage-key fingerprint.
Sourcefn quota_mode(&self) -> QuotaMode
fn quota_mode(&self) -> QuotaMode
Returns whether quota exhaustion is enforced or shadowed.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".