pub struct RateLimitInfo {
pub requests_limit: Option<u32>,
pub requests_remaining: Option<u32>,
pub requests_reset: Option<String>,
pub tokens_limit: Option<u32>,
pub tokens_remaining: Option<u32>,
pub tokens_reset: Option<String>,
pub retry_after: Option<Duration>,
}models and anthropic only.Expand description
Rate limit information parsed from Anthropic response headers.
Anthropic returns rate-limit state via HTTP response headers on every API call. This struct captures those values for caller inspection and retry decisions.
§Example
use adk_model::anthropic::RateLimitInfo;
let info = RateLimitInfo::default();
assert!(info.requests_limit.is_none());
assert!(info.retry_after.is_none());Fields§
§requests_limit: Option<u32>Maximum requests allowed in the current window.
requests_remaining: Option<u32>Remaining requests in the current window.
requests_reset: Option<String>Timestamp when the request limit resets (ISO 8601).
tokens_limit: Option<u32>Maximum tokens allowed in the current window.
tokens_remaining: Option<u32>Remaining tokens in the current window.
tokens_reset: Option<String>Timestamp when the token limit resets (ISO 8601).
retry_after: Option<Duration>Server-suggested retry delay from the retry-after header.
Implementations§
Source§impl RateLimitInfo
impl RateLimitInfo
Sourcepub fn from_headers(headers: &HashMap<String, String>) -> RateLimitInfo
pub fn from_headers(headers: &HashMap<String, String>) -> RateLimitInfo
Parse rate-limit information from HTTP response headers.
Accepts a map of lowercase header names to their string values.
Extracts all anthropic-ratelimit-* headers and the retry-after
header. Missing or unparseable headers are represented as None.
§Example
use std::collections::HashMap;
use adk_model::anthropic::RateLimitInfo;
let mut headers = HashMap::new();
headers.insert("anthropic-ratelimit-requests-remaining".to_string(), "5".to_string());
headers.insert("retry-after".to_string(), "30".to_string());
let info = RateLimitInfo::from_headers(&headers);
assert_eq!(info.requests_remaining, Some(5));
assert_eq!(info.retry_after, Some(std::time::Duration::from_secs(30)));Trait Implementations§
Source§impl Clone for RateLimitInfo
impl Clone for RateLimitInfo
Source§fn clone(&self) -> RateLimitInfo
fn clone(&self) -> RateLimitInfo
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RateLimitInfo
impl Debug for RateLimitInfo
Source§impl Default for RateLimitInfo
impl Default for RateLimitInfo
Source§fn default() -> RateLimitInfo
fn default() -> RateLimitInfo
Source§impl PartialEq for RateLimitInfo
impl PartialEq for RateLimitInfo
Source§fn eq(&self, other: &RateLimitInfo) -> bool
fn eq(&self, other: &RateLimitInfo) -> bool
self and other values to be equal, and is used by ==.