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 · 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
impl StructuralPartialEq for RateLimitInfo
Auto Trait Implementations§
impl Freeze for RateLimitInfo
impl RefUnwindSafe for RateLimitInfo
impl Send for RateLimitInfo
impl Sync for RateLimitInfo
impl Unpin for RateLimitInfo
impl UnsafeUnpin for RateLimitInfo
impl UnwindSafe for RateLimitInfo
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request