1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//! Core rate limiting algorithm implementations.
//!
//! This module contains the core algorithms for various rate limiting strategies.
//! Each core provides a thread-safe, low-level implementation that can be used
//! to build higher-level rate limiter abstractions.
//!
//! # Available Algorithms
//!
//! - **[`TokenBucketCore`]** - Allows bursts up to capacity while maintaining average rate
//! - **[`FixedWindowCounterCore`]** - Simple window-based counting with reset at boundaries
//! - **[`SlidingWindowCounterCore`]** - Accurate sliding window using multiple buckets
//! - **[`ApproximateSlidingWindowCore`]** - Memory-efficient approximate sliding window
//!
//! # Algorithm Comparison
//!
//! | Algorithm | Memory Usage | Accuracy | Burst Handling | Use Case |
//! |-----------|-------------|----------|----------------|----------|
//! | Token Bucket | Low | High | Allow bursts | Bursty traffic |
//! | Fixed Window | Low | Medium | Boundary bursts | Simple counting |
//! | Sliding Window | Medium | High | Smooth bursts | Accurate limiting |
//! | Approximate SW | Low | Good | Good | Efficient approximation |
//!
//! # Thread Safety
//!
//! All cores use internal mutexes and provide thread-safe operations through
//! the `try_acquire_at` method, which may return `ContentionFailure` if the
//! lock cannot be acquired immediately.
pub use TokenBucketCore;
pub use TokenBucketCoreConfig;
pub use FixedWindowCounterCore;
pub use FixedWindowCounterCoreConfig;
pub use SlidingWindowCounterCore;
pub use SlidingWindowCounterCoreConfig;
pub use ApproximateSlidingWindowCore;
pub use ApproximateSlidingWindowCoreConfig;