pub fn record_timestamp_with_cleanup(
timestamps: &mut Vec<Instant>,
timestamp: Instant,
window_duration: Duration,
max_capacity: Option<usize>,
auto_cleanup: bool,
) -> usizeExpand description
Record a new timestamp and perform cleanup if needed
This function adds a new timestamp to the collection and optionally performs cleanup of old timestamps to maintain memory efficiency.
§Arguments
timestamps- Mutable reference to a vector of timestampstimestamp- The new timestamp to recordwindow_duration- Duration of the rate limiting windowmax_capacity- Optional maximum capacity for the timestamp vectorauto_cleanup- Whether to automatically cleanup old timestamps
§Returns
The number of timestamps that were cleaned up (if any)