pub fn calculate_token_refill_ns(
elapsed_ns: u64,
window_ns: u64,
max_tokens: usize,
current_tokens: usize,
) -> usizeExpand description
Calculate token refill for nanosecond-based rate limiters
Specialized version for rate limiters that work with nanosecond timestamps instead of Duration/Instant types.
§Arguments
elapsed_ns- Nanoseconds elapsed since last refreshwindow_ns- Duration of the rate limiting window in nanosecondsmax_tokens- Maximum number of tokens in the bucketcurrent_tokens- Current number of available tokens
§Returns
The new number of available tokens (capped at max_tokens)