pub fn parse_rate_limit_headers<S>(
headers: &HashMap<String, String, S>,
) -> Vec<RestApiRateLimit>where
S: BuildHasher,Expand description
Parses rate limit headers from a HashMap of headers and returns a vector of RestApiRateLimit.
This function extracts rate limit information from headers with specific patterns (x-mbx-used-weight or x-mbx-order-count)
and converts them into RestApiRateLimit structures. It handles different intervals (seconds, minutes, hours, days)
and distinguishes between request weight and order rate limits.
§Arguments
headers- A reference to aHashMapcontaining HTTP headers
§Returns
A Vec<RestApiRateLimit> containing parsed rate limit information
§Panics
- If the static regex fails to compile (via
Regex::new(...).unwrap()), which can only happen if the literal pattern is invalid. - If a matching header’s key doesn’t actually contain both capture groups (so
caps.get(2).unwrap()orcaps.get(3).unwrap()fails).
§Examples
let headers: HashMap<String, String> = // … headers with rate limit information
let rate_limits = parse_rate_limit_headers(&headers);