pub struct RateLimitPolicy {
pub requests: NonZeroU32,
pub period: Duration,
pub burst: Option<NonZeroU32>,
pub scope: RateLimitScope,
}Expand description
Declarative rate limit translated by an HTTP or rate-limiter adapter.
Fields§
§requests: NonZeroU32Maximum steady-state requests in the period.
period: DurationLength of the rate-limit period.
burst: Option<NonZeroU32>Optional additional burst capacity.
scope: RateLimitScopeDimension used to derive the limiter key.
Implementations§
Source§impl RateLimitPolicy
impl RateLimitPolicy
Sourcepub fn new(requests: NonZeroU32, period: Duration) -> SoapResult<Self>
pub fn new(requests: NonZeroU32, period: Duration) -> SoapResult<Self>
Creates a client-IP rate limit with a non-zero period.
Sourcepub fn scope(self, scope: RateLimitScope) -> Self
pub fn scope(self, scope: RateLimitScope) -> Self
Selects the identity dimension used to derive a limiter key.
Sourcepub fn burst(self, burst: NonZeroU32) -> Self
pub fn burst(self, burst: NonZeroU32) -> Self
Adds explicit burst capacity above the steady-state limit.
Sourcepub fn validate(&self) -> SoapResult<()>
pub fn validate(&self) -> SoapResult<()>
Validates invariants after direct public-field mutation.
Trait Implementations§
Source§impl Clone for RateLimitPolicy
impl Clone for RateLimitPolicy
Source§fn clone(&self) -> RateLimitPolicy
fn clone(&self) -> RateLimitPolicy
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for RateLimitPolicy
impl Debug for RateLimitPolicy
impl Eq for RateLimitPolicy
Source§impl PartialEq for RateLimitPolicy
impl PartialEq for RateLimitPolicy
impl StructuralPartialEq for RateLimitPolicy
Auto Trait Implementations§
impl Freeze for RateLimitPolicy
impl RefUnwindSafe for RateLimitPolicy
impl Send for RateLimitPolicy
impl Sync for RateLimitPolicy
impl Unpin for RateLimitPolicy
impl UnsafeUnpin for RateLimitPolicy
impl UnwindSafe for RateLimitPolicy
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