pub fn refill_tokens_with_time_adjustment(
current_tokens: usize,
max_tokens: usize,
last_refresh: Instant,
now: Instant,
window_duration: Duration,
) -> (usize, Instant)Expand description
Calculate tokens available after time-based refill
Higher-level function that combines token calculation and proportional time adjustment. This is the main function used by rate limiters to update their state.
§Arguments
current_tokens- Current number of available tokensmax_tokens- Maximum number of tokens in the bucketlast_refresh- The last refresh timenow- Current timewindow_duration- Duration of the rate limiting window
§Returns
A tuple of (new_token_count, new_last_refresh_time)