Expand description
§Burster
Burster is a lightweigh crate providing stack allocated rate limiters with minimal dependencies.
§Available limiters
TokenBucket- basic token bucket type limiterFixedWindow- fixed window type limiterSlidingWindowLog- sliding window type limiterSlidingWindowCounter- sliding window counter type limiter (an approximation ofSlidingWindowLog)
§Platform support
On std targets you are all good to go and can use the following utility
functions for instantiating the limiters:
On no_std targets you’ll have to provide bindings to your platforms timing
functionalities and use the constructor methods:
TokenBucket::new_with_time_providerFixedWindow::new_with_time_providerSlidingWindowLog::new_with_time_providerSlidingWindowCounter::new_with_time_provider
You must provide timer access in the form of a closuse that returns current system
timestamp as a core::time::Duration from some fixed epoch in the past.
It’s a bit silly, but we use Duration instead of Instant because Instant requires std.
Structs§
- Cant
Consume - Error type indicating that the requested amount of tokens cannot be consumed from the limiter.
- Fixed
Window - Fixed window -type rate limiter
- Sliding
Window Counter - Sliding window counter -type rate limiter
- Sliding
Window Log - Sliding window log -type rate limiter
- Token
Bucket - Token bucket -type rate limiter
Traits§
- Limiter
- Common trait for all rate limiter implementations
Functions§
- fixed_
window - Build a fixed window limiter
- sliding_
window_ counter - Build a sliding window counter limiter
- sliding_
window_ log - Build a sliding window limiter
- token_
bucket - Build a token bucket limiter
Type Aliases§
- Limiter
Result - Limiter consume action result type