pub struct PropagatableRateLimits(/* private fields */);Expand description
A wrapper for RateLimits that can only be constructed by RateLimits::propagatable, ensuring
that we do not include any dimensioned rate limits in it.
Methods from Deref<Target = RateLimits>§
Sourcepub fn is_ok(&self) -> bool
pub fn is_ok(&self) -> bool
Returns true if this instance contains no active limits.
This is the opposite of is_limited.
Sourcepub fn is_limited(&self) -> bool
pub fn is_limited(&self) -> bool
Returns true if this instance contains any active rate limits.
A rate limit is considered active if it has not yet expired.
Sourcepub fn is_any_limited(&self, scopings: &[ItemScoping]) -> bool
pub fn is_any_limited(&self, scopings: &[ItemScoping]) -> bool
Returns true if this is instance contains any active rate limits
for the specified categories.
A rate limit is considered active if it has not yet expired.
Sourcepub fn is_any_limited_with_quotas<'a>(
&self,
quotas: impl IntoIterator<Item = &'a Quota>,
scopings: &[ItemScoping],
) -> bool
pub fn is_any_limited_with_quotas<'a>( &self, quotas: impl IntoIterator<Item = &'a Quota>, scopings: &[ItemScoping], ) -> bool
Returns true if this is instance contains any active rate limits
for the specified categories.
This is similar to Self::is_limited, but additionally checks for quotas with a static
limit of 0, which reject items even if there is no active rate limit in this instance.
A rate limit is considered active if it has not yet expired.
Sourcepub fn has_expired(&self, now: Instant) -> bool
pub fn has_expired(&self, now: Instant) -> bool
Returns true if any limit has expired at now.
Sourcepub fn propagatable(&self) -> PropagatableRateLimits
pub fn propagatable(&self) -> PropagatableRateLimits
Returns only the set of rate limits that can be propagated upstream. At this time, we cannot propagate dimensioned limits, so these must be filtered out.
Sourcepub fn check(&self, scoping: &ItemScoping) -> Self
pub fn check(&self, scoping: &ItemScoping) -> Self
Checks whether any rate limits apply to the given scoping.
Returns a new RateLimits instance containing only the rate limits that match
the provided ItemScoping. If no limits match, the returned instance will be empty
and is_ok will return true.
Sourcepub fn check_with_quotas<'a>(
&self,
quotas: impl IntoIterator<Item = &'a Quota>,
scoping: &ItemScoping,
) -> Self
pub fn check_with_quotas<'a>( &self, quotas: impl IntoIterator<Item = &'a Quota>, scoping: &ItemScoping, ) -> Self
Checks whether any rate limits or static quotas apply to the given scoping.
This is similar to check, but additionally checks for quotas with a static
limit of 0, which reject items even if there is no active rate limit in this instance.
Returns a new RateLimits instance containing the rate limits that match the provided
ItemScoping. If no limits or quotas match, the returned instance will be empty.
Sourcepub fn iter(&self) -> RateLimitsIter<'_> ⓘ
pub fn iter(&self) -> RateLimitsIter<'_> ⓘ
Returns an iterator over all rate limits in this collection.
Trait Implementations§
Source§impl Debug for PropagatableRateLimits
impl Debug for PropagatableRateLimits
Auto Trait Implementations§
impl Freeze for PropagatableRateLimits
impl RefUnwindSafe for PropagatableRateLimits
impl Send for PropagatableRateLimits
impl Sync for PropagatableRateLimits
impl Unpin for PropagatableRateLimits
impl UnsafeUnpin for PropagatableRateLimits
impl UnwindSafe for PropagatableRateLimits
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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 more