//! ## Overview
//! A Redis-backed rate-limiting middleware for Tower using [Fred](https://crates.io/fred).
//!
//! Rate-limiting is based on the [GCRA](https://liliace.dev/posts/intuition-of-the-gcra),
//! which allows one request every [`emission_interval`], with unused allowance accumulating up to [`capacity`] to allow bursts.
//!
//! ## Required permissions
//! Besides the commands Fred internally calls for all connections,
//! this crate additionally uses the following commands:
//! - [`EVALSHA`](https://valkey.io/commands/evalsha/)
//! - [`GET`](https://valkey.io/commands/get/)
//! - [`SCRIPT LOAD`](https://valkey.io/commands/script-load/)
//! - [`SET`](https://valkey.io/commands/set/)
//! - [`TIME`](https://valkey.io/commands/time/)
//!
//! ## Limitations
//! All of [Redis](https://redis.io/), [Valkey](https://valkey.io/), and [Redict](https://redict.io/) currently embed [Lua](https://www.lua.org/) 5.1.
//! Until they upgrade it to 5.3 or later, integers are stored as doubles, which start losing precision beyond 2^53.
//! This occurs if the rate limit resets after May 2057, which is possible (but strongly discouraged) with improperly high [`capacity`] and [`emission_interval`], combined with heavy traffic.
//!
//! [`emission_interval`]: RateLimitLayerBuilder::emission_interval
//! [`capacity`]: RateLimitLayerBuilder::capacity
//!
//! ## Features
//! Name | Default | Description
//! ---|---|---
//! tracing | | Enable tracing. Keys are recorded as `&str`s if valid UTF-8, or as raw `&[u8]` otherwise
//!
//! ## Example
//! ```
#![doc = include_str!("../examples/axum.rs")]
//! ```
mod config;
mod future;
mod key_resolver;
mod layer;
mod rate_limit;
mod service;

pub use fred::types::Key;
pub use key_resolver::*;
pub use layer::*;
pub use rate_limit::rate_limit;
