https://github.com/nathan-fiscaletti/tokenbucket-rs
A TokenBucket algorithm implementation for Rust
https://github.com/nathan-fiscaletti/tokenbucket-rs
bucket rust token tokenbucket
Last synced: 3 months ago
JSON representation
A TokenBucket algorithm implementation for Rust
- Host: GitHub
- URL: https://github.com/nathan-fiscaletti/tokenbucket-rs
- Owner: nathan-fiscaletti
- License: mit
- Created: 2020-08-21T19:23:08.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-11-03T23:01:29.000Z (7 months ago)
- Last Synced: 2025-03-18T03:22:35.618Z (3 months ago)
- Topics: bucket, rust, token, tokenbucket
- Language: Rust
- Homepage:
- Size: 19.5 KB
- Stars: 2
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# tokenbucket
[](https://docs.rs/tokenbucket/)
[](https://github.com/nathan-fiscaletti/tokenbucket-rs/blob/master/LICENSE)
[](https://crates.io/crates/tokenbucket)This library provides a TokenBucket Algorithm implementation for the Rust programming language.
## Install
Add the following to your Cargo.toml
```toml
[dependencies]
tokenbucket = "0.1.6"
```## Usage
```rust
use tokenbucket::{TokenBucket, TokenAcquisitionResult};fn main() {
let mut bucket = TokenBucket::new(5.0, 100.0);
match bucket.acquire(1.0) {
Ok(rate) => println!("rate/allow: {}, true", rate),
Err(rate) => println!("rate/allow: {}, false", rate),
}
}
```> See [the documentation](https://docs.rs/tokenbucket/) for more advanced usage examples.