Function cleanup_timestamps_by_duration

Source
pub fn cleanup_timestamps_by_duration(
    timestamps: &mut Vec<Instant>,
    window_duration: Duration,
    now: Instant,
) -> usize
Expand description

Clean up timestamps older than the specified duration from now

Convenience function that calculates the cutoff time based on the current time and a duration, then calls cleanup_old_timestamps.

§Arguments

  • timestamps - Mutable reference to a vector of timestamps
  • window_duration - Duration of the rate limiting window
  • now - Current time instant

§Returns

The number of timestamps that were removed