throttle_my_fn: A Rust attribute macro to throttle the execution of functions

License

throttle_my_fn is a Rust attribute macro to limit a function's number of runs over a specified period of time.

Usage

Add the dependency to your Cargo.toml:

toml [dependencies] throttle_my_fn = "0.1"

Or, using cargo add:

sh $ cargo add throttle_my_fn

Include the macro:

rust use throttle_my_fn::throttle;

Annotate the functions you want to throttle:

```rust

[throttle(10, Duration::from_secs(1))]

pub(crate) fn run10timespersecond(arg: &str) -> String { ... }

[throttle(1, Duration::from_millis(100))]

pub(crate) fn runonceper100milliseconds(arg: &str) -> String { ... } ```