struct RateLimit {
timestamp: Instant,
limit_requests: u32,
limit_tokens: u32,
remaining_requests: u32,
remaining_tokens: u32,
reset_requests: Duration,
reset_tokens: Duration,
}
Expand description
Rate Limit 情報。
HTTP レスポンスヘッダに含まれる。
Fields§
§timestamp: Instant
§limit_requests: u32
§limit_tokens: u32
§remaining_requests: u32
§remaining_tokens: u32
§reset_requests: Duration
§reset_tokens: Duration
Implementations§
Source§impl RateLimit
impl RateLimit
fn from(resp: &Response) -> Result<Self>
Sourcefn to_secs_f64(s: &str) -> Result<f64>
fn to_secs_f64(s: &str) -> Result<f64>
サンプルには “6m0s” と書かれているが、 実際には “30.828s” のように小数が来ている。 また、“120ms” とかもある。
Sourcefn calc_expected_current(&self) -> ExpectedRateLimit
fn calc_expected_current(&self) -> ExpectedRateLimit
情報のタイムスタンプと現在時刻から、現在の推測値を計算する。
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RateLimit
impl RefUnwindSafe for RateLimit
impl Send for RateLimit
impl Sync for RateLimit
impl Unpin for RateLimit
impl UnwindSafe for RateLimit
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
Mutably borrows from an owned value. Read more
§impl<T> CloneDebuggableStorage for Twhere
T: DebuggableStorage + Clone,
impl<T> CloneDebuggableStorage for Twhere
T: DebuggableStorage + Clone,
fn clone_storage(&self) -> Box<dyn CloneDebuggableStorage>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> CloneableStorage for T
impl<T> CloneableStorage for T
fn clone_storage(&self) -> Box<dyn CloneableStorage>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
Converts
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>
Converts
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 more