Skip to main content

RateLimitPolicy

Trait RateLimitPolicy 

Source
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§

Source

fn id(&self) -> &PolicyId

Returns the application-defined policy identifier.

Source

fn scope(&self) -> &ScopeId

Returns the application-defined policy scope.

Source

fn quota(&self) -> u64

Returns the quota replenished during Self::quota_period.

Source

fn quota_period(&self) -> Duration

Returns the period during which Self::quota is replenished.

Source

fn capacity(&self) -> u64

Returns the largest single cost and maximum immediately available allowance supported by this policy.

Source

fn fingerprint(&self) -> PolicyFingerprint

Returns the deterministic storage-key fingerprint.

Source

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".

Implementors§