Reference

API Reference Guide

Map of v2 providers, configuration types, decisions, reads, updates, and key lifecycle.

This page is a compact API map. The linked concept pages explain behavior and tradeoffs; generated docs.rs documentation contains exhaustive signatures and constructor lists.

A comparison gate branches into a replacement history stack and an ordered history-preservation path.
Conditional writes change state only after a comparator matches, then replace history or preserve one side of it.

Providers

ProviderConstructionKeysCalls
LocalRateLimiterProviderbuilder()&strsynchronous
RedisRateLimiterProviderbuilder(connection)&RedisKeyasync
HybridRateLimiterProviderbuilder(connection)&RedisKeyasync

Each provider exposes .absolute() and .suppressed().

Shared types

TypeRole
RateLimiterBuildershared builder trait
RateLimitvalidated rate, normalized per second
WindowSize, BucketSizelive-history duration and grouping precision
HardLimitFactormultiplier from soft target to full suppression
SuppressionFactorCachePeriodsuppression-factor cache duration
RateLimitDecisionadmission result and rejection metadata
SuppressedRateLimitSnapshotsuppressed live read
RateLimitComparatorguard over the current live total
HistoryPreservationnewest/oldest retention policy
ConditionalSetOutcomematch status and before/after totals
RedisKeyvalidated Redis/hybrid namespace or subject key
SyncIntervalhybrid synchronization cadence

Operations

  • inc(...): establish admission, then record allowed usage.
  • is_allowed(...): absolute admission check without increment.
  • get(...): live total or suppressed snapshot; unknown keys return zero without insertion.
  • get_suppression_factor(...): suppressed pressure; unknown keys return 0.0.
  • set_rate_limit(...): update an existing sticky rate without replacing live history.
  • delete(...): remove one key and return its live absolute or accepted suppressed usage.
  • clear(): remove every key for the called strategy under its configured prefix.
  • set_if(...): comparator-gated history replacement.
  • set_if_preserve_history(...): comparator-gated update retaining newest or oldest history.
  • Hybrid get_estimate(...): local estimate when state permits, Redis refresh otherwise.

Reads may lazily evict expired buckets. Matched zero conditional updates remove state. Absolute admission remains best-effort under concurrency.